Available through the player instance. To get it, create a player:
const player = await oberplayer(document.querySelector('#player_container')).setup({
playlist: [
{
videoUrl: 'https://cdn.oberplayer.com/fixtures/mp4/bbb_27s_4k.mp4'
}
]
Now, call any function as follows:
player.api.setVolume(0.5);
Function reference
play()
Description
Use the video provider play function. It returns a Promise, which is resolved when playback has been successfully started.
A failure to begin playback for any reason, such as permission issues, leads to a rejected Promise.
Parameters
Return value
Description | Type |
---|
Promise result (nothing or error) | Promise |
Example
player.api.play().then(() => {
console.log('Play call succeeded')
}).catch((err) => {
console.error(error)
})
pause()
Parameters
Return value
togglePlay()
Description
Toggles player state from paused to playing and from playing to paused
Parameters
Return value
Description |
---|
Same as play() or pause() according to the initial player state |
seek()
Description
Moves the current playback to the given position in seconds
Parameters
| Parameters | Type |
| ----------- |
| Position in seconds | Number |
Return value
getPosition()
Description
Return the current playback position in seconds
Parameters
Return value
Description | Type |
---|
Position in seconds | Number |
With live videos, the position returned will be the DVR position, if any.
getVolume()
Description
Returns the current video volume from 0 to 1
Parameters
Return value
Description | Type |
---|
Volume from 0 to 1 | Number |
Volume is independent of the mute state. A volume value of 1 doesn't mean that the sound can be heard.
setVolume()
Description
Sets the current video volume to the given value
Parameters
Return value
Same notice as getVolume()
getDuration()
Description
Returns the duration of the video in seconds. Live video duration is always -1.
Parameters
Return value
Description |
---|
Duration in seconds |
getMute()
Description
Returns muted state of the video.
Parameters
Return value
Description | Type |
---|
Muted state | Boolean |
setMute()
Description
Sets the video to the given muted state
Parameters
Parameters | Type |
---|
Muted | Boolean |
Return value
toggleMute()
Description
Inverts the muted state of the video
Parameters
Return value
toggleFullScreen()
Description
Inverts the fullscreen state of the video
Parameters
Return value
getState()
Description
Returns the player's state
Parameters
Return value
Description | Type |
---|
'paused', 'ended', 'playing' | String |
setPlaybackRate()
Description
Sets the rate at which the media is being played back. 1.0 is "normal speed". Values lower than 1.0 make the media play slower than normal and higher values make it play faster.
Parameters
Return value