VLC-RC: a ruby wrapper to the VLC TCP interface
NOTE: This project will get fixed up as soon as I have a chance
Allows control of a VLC instance through a ruby object. Uses VLC's built-in TCP interface to send commands and recieve information.
Main commands (play/pause/stop/etc.)
Status information (position/filename/length/playing?/etc.)
Allows multiple instances of VLC to be controlled
Allows launching and termination of a VLC instance
Playlist management [planned]
Command line control (simpler than VLC's Telnet interface) [planned]
VLC-RC is a library for controlling VLC and includes a CLI wrapper for VLC's built-in TCP interface since that can be a little confusing. To use this Ruby binding for the TCP interface, look at this to initialise the connection.
require 'vlcrc' # Create a new VLC object, which attempts to connect vlc = VLCRC::VLC.new localhost, 1234 # Launch an instance of VLC bound to the above socket vlc.launch # Connect to it (have to wait for it to launch though) until vlc.connected? sleep 0.1 vlc.connect end
VLC can be configured to run with the RC interface open by default on a certain socket so that you can connect to instances of VLC that are already open. Note that different instances need to run on different sockets. Now that it's up and running,
# Start playing a file vlc.media = "/path/to/a/video.avi" # Seek to the middle of the file middle = ( vlc.length / 2 ).round vlc.position = middle # Add a bunch of files and move around vlc.playlist = [ "/path/to/first/file.avi", "/path/to/another/one.mkv", "/path/to/something/else.mp4" ] vlc.skip vlc.media #=> "/path/to/another/one.mkv" # Stop the file vlc. = false # Close VLC vlc.exit
To run the specs, you'll need to add at least one video file to spec/data (anything that VLC can open will do). Just pop the file(s) in, and then the specs should run without issue.
This is pretty basic, there are a few main methods demonstrated below. If you want more control, then go for the full shebang: use VLC's Telnet interface.
Copyright © 2011 Carl Suster
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.