Skip to content

lpradovera/vlcrc

 
 

Repository files navigation

VLC-RC: a ruby wrapper to the VLC TCP interface

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]

Usage

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.playing = 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.

CLI

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.

vlcrc --help

Requires

VLC-RC needs all this stuff

  • ruby (>= 1.9.2)

  • rubygems (>= 1.3.6)

  • rspec (~> 2.5.0, development)

  • bundler (~> 1.0.0, development)

  • rake (>= 0, development)

  • trollop (~> 1.16.2)

  • vlc (>= 1.1.0)

Acknowledgement

Thanks to these sources, used as references during development

License

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.

About

Rubygem for controlling VLC through a TCP socket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 71.2%
  • Perl 28.8%