For more information, see detailed documentation available at player.js website.
Quickstart
After loading the library and embedding the Player iframe, you can create a player object and interact with it using various events and methods. The following example illustrates the basic usage:Methods
The Bunny Stream Player provides the following methods for controlling playback:play: Play the media. Example:
pause: Pause the media. Example:
getPaused: boolean - Determine if the media is paused. Example:
mute: Mute the media. Example:
unmute: Unmute the media. Example:
getMuted: boolean - Determine if the media is muted. Example:
setVolume: Set the volume. Value needs to be between 0-100. Example:
getVolume: number - Get the volume. Value will be between 0-100. Example:
getDuration: number - Get the duration of the media is seconds. Example:
setCurrentTime: number - Perform a seek to a particular time in seconds. Example:
getCurrentTime: number - Get the current time in seconds of the video. Example:
setLoop: boolean - Set whether the media should replay when it reaches the end. Example:
getLoop: boolean - Determine whether the media is set to loop. Example:
setPlaybackRate: number - Set the playback speed. Example:
getPlaybackRate: number - Get the current playback speed. Example:
The playback rate methods need player.js 0.1.2 or later. On earlier versions, and on the upstream Embedly build, send the command instead:
off: Remove an event listener. If the listener is specified it should remove only that listener, otherwise remove all listeners. Example:
on: Add an event listener. Example:
supports: [‘method’, ‘event’], methodOrEventName - Determines if the player supports a given event or method. Example:
Events
The Bunny Stream Player provides a set of events that can be used to enhance and customize your media playback experience. These events can be attached using theon method in the player.js script.
Event list
The Bunny Stream Player emits the following player.js events that can be attached using theon method:
ready - Fires when the media is ready to receive commands. This fires whether or not you are listening for it. Its payload carries src, events and methods, which is what makes supports accurate.
As outlined in the PlayerJs Spec, there may be inconsistencies if multiple players on the page have the same source
src. To address this, append a UUID or a timestamp to the iframe’s src to ensure all players on the page have a unique source.progress - Fires when the media is loading additional media for playback. Example:
timeupdate - Fires during playback. Example:
play - Fires when the video starts to play.
pause - Fires when the video is paused.
ended - Fires when the video is finished.
seeked - Fires when the video has been seeked by the user.
playbackratechange - Fires when the playback rate changes. The callback receives the new rate:
error - Fires when a command fails, and when the media itself fails to play. A failed command carries a code and a message. A media error carries an empty payload. Example: