Use Player methods (Web)
Methods allow you to initialize and control Players behavior programmatically, customize the user experience and create dynamic interactions.
Once you’ve access to a Player on a page, you can control that Player programmatically using methods.
Find all available methods in the Web SDK Reference.
Example 1: Use the callback function `onScriptLoaded()`
The callback function can be used to determine when the Player Library Script is loaded and the global Dailymotion variable is initialized.
if (window.dailymotion === undefined) {
window.dailymotion = {
onScriptLoaded: () => {
// Create a video player when script has loaded
}
}
} else {
// Script already loaded
}Example 2: Access Player settings
It’s possible to retrieve the initial Player configuration including the Player ID using the getSettings() method. On resolve, this method returns an object representation of the Player configuration.
dailymotion
.getPlayer()
.then((player) => {
console.log(player.getSettings());
})
.catch((e) => console.error(e));Which will log the following Player settings object:
{
"aspectRatio": "16:9",
"autostart": "on",
"color": "D0021B",
"enableAdsControls": true,
"enableAutonext": true,
"enableChannelLink": true,
"enableContextualContent": true,
"enableCustomRecommendations": true,
"enableDMLogo": true,
"enableInfo": true,
"enablePlaybackControls": true,
"enableAutomaticRecommendations": true,
"enableSharing": true,
"enableSharingUrlLocation": false,
"enableStartPipExpanded": false,
"enableStartscreenDMLink": false,
"enableTitlesInVideoCards": true,
"enableVideoTitleLink": true,
"enableWaitForCustomConfig": true,
"id": "PLAYER_ID",
"pip": "instant",
"watermarkImageType": "from_channel",
"watermarkImageUrl": "",
"watermarkLinkType": "from_channel",
"watermarkLinkUrl": ""
}Updated 23 days ago
