
How to Dynamically add captions do the player?
I have a list of videos on my website and I have a list of captions in a database, in this case a video can have no caption or can have 1 or more captions. I would like to know if there is a way to add captions dynamically using a javascript function?
here is a sample of my code:
<script>
function playTrailer(key,caption) {
jwplayer().load([{
file: "http://www.youtube.com/watch?v=" + key,
tracks: [{
file: caption,
label: "English",
kind: "captions",
"default": true
}]
}]);
jwplayer().play();
}
</script>
<a href="javascript:playTrailer('rKJamuzagI8','http://www.mysite.com/s1a1e1l1.srt')">Test</a>
I would like to send an array of subtitles to the function and add them dynamically to the player.
Thank you.