Reputation: 38
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
Upvotes: 0
Views: 6955
Reputation: 1596
It's not possible to directly activate subtitles with a random value.
With an API call you can retrieve the list of available subtitles for a specific video by using the endpoint: https://api.dailymotion.com/video/{id_of_video}/subtitles
Documentation
If you are in a browser, you can maybe use the navigator.language
to set the value of the subtitles.
With the dailymotion-sdk-js (Documentation), you can use the events to set your subtitle randomly:
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])
}
});
Upvotes: 1