I want to catch the event, when the users clicks on any Dailymotion video.
When there is only one video on the page, it is clear.
// Get access to the embedded player instance using one of the get player methods.
const callback = (state) => {
}
dailymotion
.getPlayer()
.then((player) => {
// Add an event listener to the event 'PLAYER_START'
player.on(dailymotion.events.PLAYER_START, callback)
});
But there are several videos.
Also there are some videos which are loaded by ajax on button click.
var player = dailymotion.createPlayer(iframeID, {
video: videoSrc,
params: {
},
})
.then((player) => console.log(player));
How can I add the listener for them?
2
Answers
Resolved based on the answer of @Milos Stojanovic.
For videos which are loaded by ajax on button click.
Maybe something like this: