Reputation: 375
I need to set a video caption track as default dynamically, I feel I missing some detail do reach it.
Part of my code is this:
track = document.createElement("track");
track.kind = "captions";
track.label = "Português";
track.srclang = "pt";
track.src = "captionsXYZ.vtt";
I tried do make that caption as default, doing this:
track.setAttribute('default', '');
and this
track.setAttribute('default', 'default')
But it shows up like this on browser:
<track label="Ligar" kind="captions" srclang="pt" src="captionsXYZ.vtt" default="">
And I need to be like this:
<track label="Ligar" kind="captions" srclang="pt" src="captionsXYZ.vtt" default>
But why do I need that?
I am working with a video player called plyr.io which is very good, mas it need caption is set default to show cc button, otherwise it doesn't show up. I did a manual test with FF inspector, deleting what I do not need it worked beautifully!
So, do you wise people have any clue?
I thank you all in advance.
Upvotes: 3
Views: 1635
Reputation: 375
Found it, friends.
Going a little deeper into plyr.io code I found a setup that solves my problem.
const player = new Plyr.setup('video', {
captions: {
active: true,
update:true,// THAT line solved my problem
}
})
Upvotes: 2
Reputation: 1247
track.setAttribute('default', '');
works for me
Is this what you are trying to achieve or did I read the question wrong? :)
Upvotes: 0