Skip to content
Alexandru Branza edited this page May 9, 2016 · 30 revisions

Player Functions

.addPlayer(parameters) - adds the player to any element of the page, should only be used once when declaring the player (parameters is optional, see supported parameters and demo usage)

.state() - get state in human readable format (can be "idle", "opening", "buffering", "playing", "paused", "stopping", "ended" or "error")

.stateInt() - get state in int format - Idle = 0, Opening = 1, Buffering = 2, Playing = 3, Paused = 4, Stopping = 5, Ended = 6, Error = 7

Playback Functions

.play(mrl) - start playing the current playlist item, if mrl is passed, it will play it without adding it to the playlist, but will only work if the player is stopped when using it

.pause() - pause player

.togglePause() - toggles pause

.stop() - stops the player

.playing() - returns true if the player is playing or false otherwise

.position(float) - get/set normalized position in multimedia stream item given as a float value between [0.0 - 1.0]

.time(i) - get/set playback time in milliseconds

.rate(i) - get/set input speed given as float (1.0 for normal speed, 0.5 for half speed, 2.0 for twice as fast, etc.)

Video Functions

.width() - get video's original width

.height() - get video's original height

.length() - get video's total length in milliseconds

.aspectRatio(string) - string, get/set aspect ratio (common values are "Default", "1:1", "4:3", "16:9", "16:10", "2.21:1", "2.35:1", "2.39:1", "5:4")

.crop(string) - string, get/set crop (common values are "Default", "16:10", "16:9", "1.85:1", "2.21:1", "2.35:1", "2.39:1", "5:3", "4:3", "5:4", "1:1")

.zoom(i) - int/float, get/set zoom, can be any positive number or float including 0 (zero hides the video feed completely)

.deinterlace(string) - string, set deinterlace mode (can be 'disabled', 'blend', 'bob', 'discard', 'linear', 'mean', 'x', 'yadif' or 'yadif2x')

.fps() - get video's frames per second returned as a float (typically 60.0, 50.0, 23.976, etc.)

Playlist Functions

.addPlaylist(playlist) - Adds videos to the playlist (accepts strings, arrays and objects, see supported parameters and demo usage)

.next() - iterate to the next playlist item

.prev() - iterate to the previous playlist item

.itemCount() - returns the number of playlist items

.itemDesc(i) - returns the media object

.currentItem(i) - get/set the current playlist item

.playItem(i) - set the current playing playlist item

.removeItem(i) - removes a playlist item

.clearPlaylist() - clears the current playlist and stops the player

.advanceItem(i, count) - change item position within playlist

Audio Functions

.volume(i) - get/set volume (can be an integer between 0 and 200, if no value set it will return the current volume)

.toggleMute() - toggle mute

.mute(bool) - get/set mute (boolean, if no value set it will return the current mute state)

.audioCount() - returns the number of audio tracks available

.audioTrack(i) - gets/sets currently playing audio track by index number, a value of 0 means the audio is/will be disabled

.audioDesc(i) - returns the i-th audio track name. 0 corresponds to disable and 1 to the first audio track

.audioDelay(i) - change audio track delay (in milliseconds, can be positive or negative number)

.audioChan(string) - string, get/set audio channel (can be "error", "stereo", "reverseStereo", "left", "right" or "dolby")

.audioChanInt(i) - int, get/set audio channel in int format - Error = -1, Stereo = 1, Reverse Stereo = 2, Left = 3, Right = 4, Dolby = 5

Subtitle Functions

External subtitles are set in .addPlaylist()

.subTrack(i) - get/set the currently playing subtitle (internal video subtitles and external subtitles)

.subDesc(i) - returns an object with information about the subtitle track (includes: language, type, url, ext)

.subDelay(i) - change subtitle track delay (in milliseconds, can be positive or negative number)

.subCount() - returns the total number of subtitles (interval video subtitles and external subtitles)

UI Functions

.toggleFullscreen() - toggles fullscreen mode

.fullscreen(bool) - boolean, true - maximize, false - minimize, if no value set, it will return the screen state

.playlist(bool) - optional boolean, sets playlist menu visibility, if no value set, it will return the playlist menu HTML element

.subtitles(bool) - optional boolean, sets subtitle menu visibility, if no value set, it will return the subtitle menu HTML element

.ui(bool) - boolean, sets User Interface visibility

.video(bool) - boolean, hide/show the video feed

.notify(string) - string, echoes a message to the video surface. (the text slowly fades out after 1 second)

.animatePause() - call after using .play(), .pause() or .togglePause() to start the Pause / Play animation.

Events

.onMediaChanged(function) - triggers when the playlist item has changed

.onIdle(function) - triggers when the player enters idle state

.onOpening(function) - triggers when the player enters opening state

.onBuffering(function) - triggers when the player is in buffering state

.onPlaying(function) - triggers when the player enters playing state (at the start of playback and when switching from pause to play)

.onFirstPlay(function) - triggers when the player starts playing a new media file

.onPaused(function) - triggers when the player enters paused state

.onStopped(function) - triggers when the player enters stopped state

.onEnded(function) - triggers when the player finished playing all playlist items

.onError(function) - triggers when the player has encountered an error and is unable to continue

.onState(function) - triggers when the event has changed (returns a string, can be "idle", "opening", "buffering", "playing", "paused", "stopping", "ended" or "error")

.onStateInt(function) - triggers when the event has changed (returns a int, values can be 0 - 7)

.onTime(function) - triggers when the player's time changed (returns a int, the current playback position in milliseconds)

.onPosition(function) - triggers when the player's position changed (returns a float, the current playback position from 0.0 to 1.0)

.onVolume(function) - triggers when the volume changes, this is needed to know the last volume as restarting NW.js or Electron will reset the volume to 50%, you should always reset the volume to the last recorded one in the very first playing event (.onPlaying()) as VLC does not allow changing volume or pausing until the very first play

.onForward(function) - triggers when the player's fastforwarding through the media (works only when an input supports forward playback)

.onBackward(function) - triggers when the player's going backwards through the media (works only when an input supports backwards playback)

.onFrameSetup(function) - triggers when the video's first frame is received, can be used to get the width and height of the video if you need it as soon as it becomes available (returns width, height, pixelFormat and videoFrame, the last two are only required by the wcjs-renderer module)