dailymotion-api

How can I activate subtitles by default in the Dailymotion embedded player for any language


Dailymotion embed URLs can activate subtitles by default:

https://www.dailymotion.com/embed/video/x7n59nb?subtitles-default=en

But the embed player needs to know the language for that.

It would be nice to be able to activate subtitles regardless of language for the video software I am using, as I don't want to store the language for every video.

Is there a way to activate just any subtitle eg:

https://www.dailymotion.com/embed/video/x7n59nb?subtitles-default=any (or first)

Or to give the player a list of possible subtitles:

https://www.dailymotion.com/embed/video/x7n59nb?subtitles-default=de,en


Solution

  • It's not possible to directly activate subtitles with a random value.

    var player = DM.player(document.getElementById("player"), {
            video: "x7n59nb"
        });
    
        player.addEventListener('playback_ready', function (e)
            { 
                if(e.target.subtitles.length > 0){
                    var random = Math.floor(Math.random() * Math.floor(e.target.subtitles.length));
                    playlists.setSubtitle(e.target.subtitles[random])
                }
            });