Web SDK - Player methods

The Player is loaded asynchronously using a Promise, which on resolve returns a player object. In order to get access to a Player, you can retrieve a Player using one of the below methods. API commands can be called to programmatically create and control a Player. Once you have access to a Player on a page, you can control that Player programmatically.




Initialize & destroy Player (web)

MethodsDescription
onScriptLoaded()Check if the Player Library Script is fully loaded before using any other method to interact with the Player.
createPlayer()Create a new video Player on a web page.
getPlayer()On resolve, the Promise will return a player if there is a single player instance. Otherwise, it will be rejected if there are multiple player embeds.
getPlayer('source_id')On resolve, the Promise will return the specified player, pass the container ID of the specific player as an argument into the getPlayer() method.
getAllPlayers()Returns an array of promises. Each promise returns one of the player of the page.
destroy()To destroy a Player instance, pass in specified Player ID.

Load content (web)

MethodsDescription
loadContent()To load a video or a playlist.
setCustomRecommendations()To set custom recommendations in the Player, giving a list of video xIDs.

Playback (web)

MethodsDescription
play()To start or resume video playback.
pause()To pause video playback.
seek()To seek to the specified time in video playback in seconds.

Advertising (web)

MethodsDescription
setCustomConfig()To set the config for ads and dynamically update the advertising parameter value.

Settings (web)

Methods

Description

setFullscreen()

To enable or disable fullscreen mode.

setQuality()

To set the video’s quality to the specified quality.

Possible values: [240, 380, 480, 720, 1080, 1440, 2160, default]

setPlaybackSpeed()

To modify the playback speed.

If the value passed does not match one from the list, the playback speed is rounded to the superior one. The playback speed is kept across videos.

Possible values: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]

setSubtitles()

To activate a subtitles track to a specified language if available.

setScaleMode()

To adjust the player view of the video screen.

Possible values: fit fill fillLeft fillRight fillTop or fillBottom

setVolume()

To set the player’s volume to the specified level.

setMute()

To set the mute mode of the player.

updateParams()

To change the following player config values at runtime: aspectRatio, customConfig, loop, mute, scaleMode & volume


Picture-in-picture (web)

MethodsDescription
pipClose()To deactivate PiP.
pipResume()To resume PiP.
pipCollapse()To collapse the mobile sticky PiP.
pipExpand()To expand the mobile sticky PiP.
pipRepaint()To repaint PiP seamlessly when dynamic elements are changing the layout of a page.

Player details (web)

MethodsDescription
getSettings()To retrieve the configuration of a Player as defined in your Dailymotion Studio.
getState()To retrieve the current state of the Player.
getRootNode()Retrieve the node where the Player iFrame is contained.

Events management (web)

MethodsDescription
on()To set up an event listener function.
off()To remove a previously registered event listener.