Uncaught (in promise) TypeError: player.mute is not a function

76 Views Asked by At

I add the event listener to the dailymotion playlists. I want to implement the following: When the event catches, get the information about the related playlist and mute it.

    // Define the callback function
const callback = (state) => {
    var player = dailymotion.getPlayer(state.id).then((player) => {
    player.mute()
    });
}

// Get access to all embedded player instances on the page
Promise.all(dailymotion.getAllPlayers()).then((players) => {
    // Add an event listener to each player for the 'PLAYER_START' event
    players.forEach((player) => {
        player.on(dailymotion.events.PLAYER_START, callback)
    });
})

I get: Uncaught (in promise) TypeError: player.mute is not a function

1

There are 1 best solutions below

0
StaceyKosheen On

I tried what was proposed by @James and @Barmar:

dailymotion.getPlayer(state.id).then((player) => {
   player.setMute(true)
});

And that worked.