1

I'm trying to add subtitles from an external source in a video html but I can't. I'm using the WebTorrent Technology, so, I'm streaming video torrents in my Browser and the <track> tag not works for me. Here's the code that I use: https://plnkr.co/edit/31RZSBETaAQgnCgZgKUt?p=preview
The code for subtitles it's this:

file.appendTo('body'); var video = document.querySelector("video"); var track = video.addTextTrack("subtitles", "prompt", "en"); track.mode = "showing"; }); 

Thanks, i hope that you can help me!

9
  • Function shows as not supported in any browser haven't seen this one so can't really speak to it: w3schools.com/tags/av_met_addtexttrack.asp Commented Jan 11, 2018 at 6:46
  • What is the issue with the code at linked plnkr? Commented Jan 11, 2018 at 6:53
  • Oh no, it´s not a issue with the code at linked plnkr. It's just that I want to add subtitles from an external source, and I don't know how to do it Commented Jan 11, 2018 at 6:59
  • Can you describe "doesn't works"? Have you created and linked to a corresponding .vtt file? Commented Jan 11, 2018 at 6:59
  • Yes, bitmovies.000webhostapp.com/subs.vtt Commented Jan 11, 2018 at 7:00

1 Answer 1

1

You can create or include a <track> element within HTML as a child of parent <video> element with default property set to true, src to to .vtt file, kind set to "subtitles", mode set to "showing", label set to "Español", and srclang set to "es"

 file.appendTo('body'); var video = document.querySelector("video"); var track = document.createElement("track"); track.mode = "showing"; track.label = "Español"; track.kind = "subtitles"; track.srclang = "es"; track.src = "subs.vtt"; track.default = true; video.appendChild(track); 

plnkr https://plnkr.co/edit/9MpJNHTB08RP6Lz3tvEb?p=preview

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.