An intuitive library to control VLC with simple function calls using VLC's own HTTP interface, written in typescript. Covers almost all of VLC's functions that can be controlled with the HTTP interface
- Play, Pause, Seek
- Get and set time, length, volume, shuffle, repeat, loop
- Playlist manipulation (add, remove, next, prev)
- Get and set audio, subtitle delay
- Change subtitle and audio tracks
- Add/Change video, audio, subs streams
- Request album art
- Lots of helper methods
- Browse for files
- Auto polling for changes
- Audio eq, effects
- VLC instances discovery on the network
npm install --save vlc-client
Typescript
import * as VLC from "vlc-client"
const vlc = new VLC.Client({
ip: "localhost",
port: 8080,
username: "steve_aoki", //username is optional
password: "edm"
});
Javascript
const VLC = require("vlc-client");
const vlc = new VLC.Client({
ip: "localhost",
port: 8080,
username: "steve_aoki", //username is optional
password: "edm"
});
All methods on the Client class are async
await vlc.isPlaying();
await vlc.pause();
await vlc.setTime(3100);
new VLC.Client(options);
options:
- ip: the ip of the computer where VLC is running
- port: port of VLC web interface
- username: username of VLC web interface
- password: password of VLC web interface
Resume the playback if paused
Pause the playback
Pauses if playing, and resumes the playback if paused
Stops the playback
Play the next media in playlist
Play the previous media in playlist
Removes all entries from the playlist
Removes the item with the given id from palylist.
To get the id see .getPlaylist().
Play an entry from playlist by id.
To get the id see .getPlaylist().
Add a file to playlist using an URI. Can be file, http, rtsp, etc. Anything VLC supports.
Play a file by specifing URI. Adds a file to the playlist and plays it imediately. Only one of the noaudio/novideo options can be set.
options:
- noaudio: boolean
- novideo: boolean
- wait: boolean - If set to true, the promise will only return after vlc opens the file.
- timeout: number - Set the timeout in ms to wait for vlc to open the file. Default = 3000
The options object is optional
Seek playback forward by given seconds
Seek playback backwards by given seconds
Toggle if VLC is fullscreen
Increase the volume by given int, range 0-100
Decrease the volume by given int, range 0-100
.browse(dir: string) => VlcFile
Browse the remote computer running the VLC instance
for files in a given directory.
Default dir: /
Returns an object with all the info that VLC provides except playlist info
.meta() => VlcMeta
Returns an object with various informations about the current media playing.
Returns the file name of the current media playing
Returns true/false if is playing
Returns true/false if is paused
Returns true/false if is stopped
Returns true/false if VLC is fullscreen
State of vlc ( playing / paused / stop ) as string
Time of playback in seconds
Media playback progress from 0-100
Length of the current media playing in seconds
Get the volume in a 0-100 range
Get the current volume as VLC represents it from 0-512, where 256 is 100% and 512 is 200%
Audio delay from video stream in seconds
Subtitle delay from video stream in seconds
.getPlaylist() => PlaylistEntry[]
Get the entries in the playlist
Returns as string the current aspect ratio
.getSubtitleTracks() => SubtitleTrack[]
Get subtitle tracks.
.getAudioTracks() => AudioTrack[]
Get audio tracks.
.getVideoTracks() => VideoTrack[]
Get video tracks.
.getTracks() => Tracks
Get all tracks/streams including video, audio, subtitles.
Returns an array of numbers representing all the chapters of a movie. Usually starts at 0.
Returns the current chapter of a video that is playing.
Returns synchronous an array of all the available aspect ratios as string array.
Return true if VLC's loop function is activated
Return true if items in playlist are played in random order. Random is same as shuffle.
Return true if repeat is on.
Playback rate. Normal speed is 1. Range 0.25 - 4.
.getAlbumArt(playlistEntryId?: number) => AlbumArtResult
Returns the album art of an item in the playlist.
If playlistEntryId is not specified, returns the album art of the current item that is playing.
Returns null if the media has no album art.
Set the time of playback. Time arg should be an int.
Set progress of media playback 0-100 range. Progress can be a number with decimals.
Set the volume range 0-100.
Set volume as VLC represents it 0-512
Set if VLC should be fullscreen
Set the aspect ratio of video. To get a list of available aspect ratios use .availableAspectRations().
Set if playlist entries should be repeated.
Set if VLC's looping function should be activated
Set if playlist entries should be played in random order
Playback rate. Normal speed is 1. Range 0.25 - 4
Set a delay in seconds, can have decimals, of the subtitle track from video track.
Set a delay in seconds, can have decimals, of the audio track from video track.
Set the chapter of the movie playing.
See .getChapters
Select the audio track. Get the audio tracks id from .getTracks() or .getAudioTracks.
Select the sub track. Get the sub tracks id from .getTracks() or .getSubtitleTracks.
Select the video track. Get the video track id from .getTracks() or .getVideoTracks.
interface PlaylistEntry{
name: string;
id: number;
duration: number;
uri: string;
isCurrent: boolean;
}
interface Tracks {
video: VideoTrack[],
audio: AudioTrack[],
subtitle: SubtitleTrack[],
}
interface VideoTrack {
streamIndex: number,
Type: "Audio" | "Video" | "Subtitle",
Language?: string,
Codec?: string,
Frame_rate: string,
Decoded_format: string,
Video_resolution: string,
Buffer_dimensions: string,
Orientation: string,
}
interface AudioTrack {
streamIndex: number,
Type: "Audio" | "Video" | "Subtitle",
Language?: string,
Codec?: string,
Channels: string,
Bits_per_sample: string,
Sample_rate: string
}
interface SubtitleTrack {
streamIndex: number,
Type: "Audio" | "Video" | "Subtitle",
Language?: string,
Codec?: string,
}
interface AlbumArtResult {
contentType: string, // image/jpeg , image/png , etc
buffer: Buffer, // album art image as buffer
}
interface VlcMeta{
showName?: string, //optional
seasonNumber?: string, //optional
episodeNumber?: string, //optional
filename:string,
[key: string]: string,
... // much more properties
}
export enum VlcFileType {
FILE = "file",
DIR = "dir"
}
export interface VlcFile {
type: VlcFileType,
path: string,
name: string,
access_time: number,
uid: number,
creation_time: number,
gid: number,
modification_time: number,
mode: number,
uri: string,
size: number;
}