-
Notifications
You must be signed in to change notification settings - Fork 4
JavaScript API
wjs selectors are used to "find" (or select) HTML elements based on their ids, classes or types. It's based on the existing CSS Selectors.
wjs("#webchimera") - The element with id="webchimera"
wjs(".webchimeras") - All elements with class="webchimeras"
wjs("object") - All <object></object> elements
If there is only one video element on the page and that html element's id is "webchimera", then you can simply use wjs().
If there is only one <object></object> html element on the page, then you can simply use wjs("object").
All WebChimera Player JavaScript API properties can be called with selectors as explained above.
.plugin - Returns the plugin object that holds the Plugin JS API
.version - Returns the player version.
.context - Returns the context in which "wjs()" was called. (ex: "#webchimera")
All WebChimera Player JavaScript API functions can be called with selectors as explained above.
.hasVout() - Returns a boolean, true: the video is being displayed, false: video is not displayed.
.width() - Returns the original width of the current playing item.
.height() - Returns the original height of the current playing item.
.fps() - Returns the frames per second of the current playing item as a float (typically 60.0, 50.0, 23.976, etc...).
.length(int) - Gets/Sets the total video's length in milliseconds. You can only set a custom total length if .length() returns 0.
.aspectRatio(string) - Sets the aspect ratio for the video, can be 1:1, 16:9, 2.21:1, etc.
.crop(string) - Sets the crop for the video, can be 1:1, 16:9, 2.21:1, etc.
.zoom(float) - Sets the zoom for the video, can be 0.25, 0.5, 1, 2, 3, etc. (default is 1)
.resetSize() - Sets video size to default.
.addPlayer(settings) - Creates the player.
.startPlayer() - Starts playback.
.stopPlayer() - Stops playback.
.isPlaying() - A boolean that returns true if the current playlist item is playing and false when it is not playing.
.state() - Returns the current state of the input chain given in human readable format.
.time(int) - Get/set playback time in milliseconds.
.rate(float) - Input speed given as float (1.0 for normal speed, 0.5 for half speed, 2.0 for twice as fast, etc.).
.position(float) - Get/set normalized position in multimedia stream item given as a float value between [0.0].
.nextFrame(milliseconds) - Jump to [current-time] + [milliseconds]. (this will also pause playback)
.addPlaylist(playlist) - Adds videos to the playlist. (also supports m3u files and advanced parameters)
.play() - Play current playlist item.
.playItem(int) - Play a specific playlist item.
.pause() - Pauses the currently playing playlist item.
.togglePause() - Pauses/plays the current playlist item.
.next() - Iterate to the next playlist item.
.prev() - Iterate to the previous playlist item.
.currentItem() - Returns current playlist item index.
.replaceMRL(int,mrl) - Replaces the video source of a playlist item.
.swapItems(int,int) - Swaps the two playlist items.
.advanceItem(int,count) - Change playlist item position within playlist.
.removeItem(int) - Removes a specific playlist item.
.itemCount() - Returns the number of items currently in the playlist.
.clearPlaylist() - Removes all videos from the playlist.
To add an external subtitle (supported: SUB, SRT and WebVTT) to the subtitle menu, use the Subtitles Parameter from .addPlaylist().
.subCount() - Returns the number of available subtitles. (internal + external)
.subTrack(int) - Gets/Sets the currently loaded subtitle track by index number, a value of 0 means that subtitles are/will be disabled.
.subDesc(int) - Returns an object of information about a given subtitle track by index number.
.subSize(int) - Change Subtitle Size.
.subDelay(int) - Change Subtitle Delay. (in milliseconds, can be positive or negative number)
.clearSubtitle() - Removes the currently loaded subtitle.
.volume(int) - 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. (if no value set it will return the current mute state)
.audioCount() - Returns the number of audio track available.
.audioTrack(int) - Gets/Sets currently playing audio track by index number, a value of 0 means the audio is/will be disabled.
.audioDesc(int) - Returns the i-th audio track name. 0 corresponds to disable and 1 to the first audio track.
.audioDelay(int) - Change Audio Track Delay. (in milliseconds, can be positive or negative number)
.qmlLoaded(function) - Attaches a function to the QML Loaded Event.
.onClicked(event,function) - Catches player button click events.
.onKeyPressed(event,function) - Catches player key press events.
.preventDefault(type,event,bool) - Disable / re-enable default actions for player button clicks or key press 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.
.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 player has changed playback state.
.onTime(function) - Triggers when the player's time changed.
.onPosition(function) - Triggers when the player's position changed.
.onVolume(function) - Triggers when the player has changed volume.
.onMute(function) - Triggers when mute state has changed.
.onMessage(function) - Triggers when the player sent a message from QML to JS.
.emitJsMessage(message) - Sends a message from JS to QML.
.catchEvent(event,function) - Adds an event listener.
.skin(settings) - Customize the player's skin with advanced parameters.
.notify(message) - Echo a message to the video surface. (the text fades out after a few seconds)
.setOpeningText(string) - Sets the opening text from the video loading screen. (default is "Loading Resource")
.toggleFullscreen() - Toggles Fullscreen Mode.
.fullscreen(bool) - Get/Set Fullscreen Mode.
.togglePlaylist() - Toggles the Playlist Menu.
.toggleSubtitles() - Toggles the Subtitle Menu.
.hideToolbar() - Hides the Toolbar.
.showToolbar() - Shows the Toolbar.
.toggleToolbar() - Toggles Toolbar Visibility.
.hideUI() - Hides the User Interface.
.showUI() - Shows the User Interface.
.toggleUI() - Toggles User Interface Visibility.
.setDownloaded(float) - Sets the video buffered percent. (in the progress bar)
These functions still work and will always work. They have been marked as deprecated because larger functions such as .addPlayer() or .addPlaylist() now also support their functionality.
.setTotalLength(int) - Sets the total video length in milliseconds. (only works if .plugin.length returns 0)
.loadM3U(m3u-playlist) - Adds a M3U Playlist to WebChimera Player. The Player will load the Video URLs and the Video Titles from the M3U File.
.startSubtitle(subtitle-url) - Adds an external subtitle to the video. (supported formats: SUB, SRT, WebVTT)
The settings parameters can only be called as [parameters] in the .addPlayer() function.
id - ID of the player to be created. (defaults to "webchimera")
class - Class of the player. (defaults to "webchimeras")
theme - Can be the relative or direct path to qml file or the theme name (folder with same name must exist in /player/themes/). (defaults to "sleek" theme)
toolbar - If the toolbar should be visible or not. default is 1
hotkeys - If the hotkeys should be enabled or not. default is 1
debug - Starts the Player in Debug Mode. (you will need to install DebugView to see the log)
debugPlaylist - Starts the Player in Debug Playlist Mode. (possible values can be true or false) default is 0
autoplay - Video will start playback automatically. default is 0
mute - Mute the video on start. default is 0
loop - Replay the video on end. default is 0
allowfullscreen - Disables player Fullscreen Mode. default is 1
buffer - Specifies the caching value (in milliseconds) for network resources. (also known as buffering cache)
multiscreen - Sets the UI to Multiscreen Mode. default is 0
mouseevents - Receive Mouse Events over the Video Layer from QML to JavaScript. default is 0
titleBar - Specifies when and if the Title Bar should be visible. (possible values can be "fullscreen", "minimized", "both" or "none") default is "fullscreen"
progressCache - Specifies if the Progress Bar Cache should be visible or not. (possible values can be true or false) default is 0
Events can be caught with the .catchEvent() function
QML Loaded - Announces when the QML File was loaded in WebChimera Plugin.
Video Layer Mouse Events - Receives JSON Encoded Mouse Events from inside WebChimera Player. (Cursor Position, Left Click, Right Click, Double Click)
Button Click Events - Player Button Click Events
Key Press Events - Hotkeys
Prevent Events - Prevent Default Actions of Button Clicks and Hotkeys
Playback Events - Playback Related Event Functions