1.1.1 • Published 1 year ago

vlc-client v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

Node VLC Client

npm NPM npm bundle size Travis (.org)

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

Features

  • 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

Installation

npm install --save vlc-client

Usage

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);

API

Contents

VLC.Client

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

Methods

Actions

.play()

Resume the playback if paused

.pause()

Pause the playback

.togglePlay()

Pauses if playing, and resumes the playback if paused

.stop()

Stops the playback

.next()

Play the next media in playlist

.previous()

Play the previous media in playlist

.emptyPlaylist()

Removes all entries from the playlist

.removeFromPlaylist(id: number)

Removes the item with the given id from palylist.
To get the id see .getPlaylist().

.playFromPlaylist(entryId: number)

Play an entry from playlist by id.
To get the id see .getPlaylist().

.addToPlaylist(uri: string)

Add a file to playlist using an URI. Can be file, http, rtsp, etc. Anything VLC supports.

.playFile(uri: string, options)

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

.jumpForward(seconds: number)

Seek playback forward by given seconds

.jumpBackwards(seconds: number)

Seek playback backwards by given seconds

.toggleFullscreen()

Toggle if VLC is fullscreen

.increaseVolume(increaseBy: number)

Increase the volume by given int, range 0-100

.decreaseVolume()

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: /

Getters

.status() => VlcStatus

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.

.getFileName() => string

Returns the file name of the current media playing

.isPlaying()

Returns true/false if is playing

.isPaused()

Returns true/false if is paused

.isStopped()

Returns true/false if is stopped

.isFullscreen()

Returns true/false if VLC is fullscreen

.getPlaybackState()

State of vlc ( playing / paused / stop ) as string

.getTime()

Time of playback in seconds

.getProgress()

Media playback progress from 0-100

.getLength()

Length of the current media playing in seconds

.getVolume()

Get the volume in a 0-100 range

.getVolumeRaw()

Get the current volume as VLC represents it from 0-512, where 256 is 100% and 512 is 200%

.getAudioDelay()

Audio delay from video stream in seconds

.getSubtitleDelay()

Subtitle delay from video stream in seconds

.getPlaylist() => PlaylistEntry[]

Get the entries in the playlist

.getAspectRatio()

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.

.getChapters() => number[]

Returns an array of numbers representing all the chapters of a movie. Usually starts at 0.

.getCurrentChapter() => number

Returns the current chapter of a video that is playing.

.availableAspectRations(): string[]

Returns synchronous an array of all the available aspect ratios as string array.

.isLooping() => boolean

Return true if VLC's loop function is activated

.isRandom() => boolean

Return true if items in playlist are played in random order. Random is same as shuffle.

.isRepeating() => boolean

Return true if repeat is on.

.getPlaybackRate() => number

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.

Setters

.setTime(time: number)

Set the time of playback. Time arg should be an int.

.setProgress(progress: number)

Set progress of media playback 0-100 range. Progress can be a number with decimals.

.setVolume(volume: number)

Set the volume range 0-100.

.setVolumeRaw()

Set volume as VLC represents it 0-512

.setFullscreen(val: boolean)

Set if VLC should be fullscreen

.setAspectRation(ar: string)

Set the aspect ratio of video. To get a list of available aspect ratios use .availableAspectRations().

.setRepeating(shouldRepeat: boolean)

Set if playlist entries should be repeated.

.setLooping(shouldLoop: boolean)

Set if VLC's looping function should be activated

.setRandom(random: boolean)

Set if playlist entries should be played in random order

.setPlaybackRate(rate: number)

Playback rate. Normal speed is 1. Range 0.25 - 4

.setSubtitleDelay(delay: number)

Set a delay in seconds, can have decimals, of the subtitle track from video track.

.setAudioDelay(delay: number)

Set a delay in seconds, can have decimals, of the audio track from video track.

.setChapter(chapter: number)

Set the chapter of the movie playing.
See .getChapters

.setAudioTrack(trackId: number)

Select the audio track. Get the audio tracks id from .getTracks() or .getAudioTracks.

.setSubtitleTrack(trackId: number)

Select the sub track. Get the sub tracks id from .getTracks() or .getSubtitleTracks.

.setVideoTrack(trackId: number)

Select the video track. Get the video track id from .getTracks() or .getVideoTracks.

Types

PlaylistEntry

interface PlaylistEntry{
	name: string;
	id: number;
	duration: number;
	uri: string;
	isCurrent: boolean;
}

Tracks

interface Tracks {
    video: VideoTrack[],
    audio: AudioTrack[],
    subtitle: SubtitleTrack[],
}

VideoTrack

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,
}

AudioTrack

interface AudioTrack {
    streamIndex: number,
    Type: "Audio" | "Video" | "Subtitle",
    Language?: string,
    Codec?: string,
    Channels: string,
    Bits_per_sample: string,
    Sample_rate: string
}

SubtitleTrack

interface SubtitleTrack {
    streamIndex: number,
    Type: "Audio" | "Video" | "Subtitle",
    Language?: string,
    Codec?: string,
}

AlbumArtResult

interface AlbumArtResult {
	contentType: string, // image/jpeg , image/png , etc
	buffer: Buffer, // album art image as buffer
}

VlcMeta

interface VlcMeta{
	showName?: string, //optional
	seasonNumber?: string, //optional
	episodeNumber?: string, //optional
	filename:string,
    [key: string]: string,
    ... // much more properties
}

VlcFile

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;
}

License

MIT

1.1.1

1 year ago

1.1.0

1 year ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.8-alpha

4 years ago

0.0.6-alpha

4 years ago

0.0.5-alpha

4 years ago

0.0.7-alpha

4 years ago

0.0.4-alpha

4 years ago

0.0.3-alpha

4 years ago

0.0.2-alpha

4 years ago

0.0.1

4 years ago