droopy-vlc

0.1.0 • Public • Published

VLC Http Service

droopy-vlc is an HTTP service that sends commands to VLC's HTTP endpoint.

Example Usage

After installing the npm module (droopy-vlc), you can require the service and start controlling Vlc.

>>npm install droopy-vlc
var VlcService = require("droopy-vlc"),
    vlc = new VlcService("http://:password@localhost:8080");
 
vlc.volume(80).then(function(vlcStatus) {
    console.log("Successfully set volume to " + vlcStatus.volume);
});
 

VLC Status

All methods return Q promises that resolve with a VlcStatus object

{
    fullscreen: 'false',
    aspectRatio: 'default',
    time: '1264',
    timeDisplay: '21:04',
    volume: '0',
    duration: '6572',
    durationDisplay: '1:49:32',
    state: 'playing',
    rate: '1',
    position: '0.19233977794647',
    filename: 'myvideofile.avi'
}

Supported Methods

status()

Passes back a VlcStatus object.

vlcService.status().then(function(status) {
    console.log(status); //You could continuously poll this
});

seek(time)

Requires a time parameter in seconds.

//move the the 2 minute mark
vlcService.seek(120).then(function(status) {
    console.log(status);
});

volume(val)

Requires a volume level between 0 and 200.

//max volume
vlcService.volume(125).then(function(status) {
    console.log(status);
});

togglePause()

If currently paused the video will play, otherwise pause.

vlcService.togglePause().then(function(status) {
    //statue.state will be "paused" or "playing"
    console.log(status);
});

fullscreen()

If currently fullscreen, it will shrink the window, else make it fullscreen

vlcService.fullscreen().then(function(status) {
    //statue.fullscreen will be "true" or "false"
    console.log(status);
});

rate(speed)

Adjusts the playback speed. Unfortunately I couldn't find a way to make it go backwords like a "rewind"

//Play 3 times as fast (fast forward)
vlcService.rate(3).then(function(status) {
    console.log(status);
});

next()

Next song in the playlist.

vlcService.next().then(function(status) {
    console.log(status);
});

previous()

Previous song in the playlist.

vlcService.previous().then(function(status) {
    console.log(status);
});

play(id)

Play song by id in the playlist.

vlcService.play().then(function(status) {
    console.log(status);
});

deleteItem(id)

Remove song by id in the playlist.

vlcService.deleteItem().then(function(status) {
    console.log(status);
});

empty()

Remove all song in the playlist.

vlcService.empty().then(function(status) {
    console.log(status);
});

playlist()

Return the actual playlist [{ name : String, duration : Number, id : Number},... ]

vlcService.playlist().then(function(vlcPlaylist) {
    console.log(vlcPlaylist);
});

loop()

Repeat the entire playlist

vlcService.loop().then(function(status) {
    console.log(status);
});

repeat()

Repeat the last song

vlcService.repeat().then(function(status) {
    console.log(status);
});

Enabling VLC Http Endpoint

VLC's Http endpoint is not enabled by default. You can enable by launching VLC with a --etraintf http flag. VideoLan documentation

UPDATE: New versions now require you to setup a password to access the HTTP endpoint. To do this go to Tools -> Preferences -> Main Interfaces -> Lua -> Lua HTTP Password.

>>C:\Program Files (x86)\VideoLAN\VLC\vlc.exe -f <filepath> --etraintf http

Opening and closing VLC with node.js

The following are helper methods that I use to launch and close VLC on Windows PC.

exec = require('child_process').exec;
 
var killVlc = function() {
    try {
        //var cmd = 'tasklist /fi "ImageName eq vlc.exe" /fo csv /nh';
        var cmd = 'taskkill /IM vlc.exe';
        var child = exec(cmd, function(err, stdout, stderr) {
            if (err) {
                console.log(err);
                console.log(stderr);
            }
        });
    } catch (ex) {
        console.log("kill catch");
    }
};
 
var launchVlc = function(filepath) {
    var params = " -f " + " \"" + filepath + "\" --extraintf http";
        
    var child = exec(options.exePath + params, function(err, stdout, stderr) {
        if (err) {
            console.log(err);
            console.log(stderr);
        }
    });
};

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    3
    • latest

Version History

Package Sidebar

Install

npm i droopy-vlc

Weekly Downloads

3

Version

0.1.0

License

BSD-2-Clause

Last publish

Collaborators

  • droopytersen