Skip to content

How to reload vtt subtitles tracks? #8773

Closed Answered by elieobeid7
elieobeid7 asked this question in Q&A
Discussion options

You must be logged in to vote

I had to add mode: "showing", thank you so much for your help.

const switchTracks = (vttFile, api_key, lang_code, language) => {
  // generate random number to avoid caching
  const random = Math.floor(Math.random() * 1000000);

  // remove all existing tracks
  console.log("removing vtt:", vttFile);
  let tracks = player.remoteTextTracks();
  let numTracks = tracks.length;
  for (let i = numTracks - 1; i >= 0; i--) {
    player.removeRemoteTextTrack(tracks[i]);
  }

  console.log("adding vtt:", vttFile);
  player.addRemoteTextTrack(
    {
      src: `${vttFile}?api_key=${api_key}&random=${random}`,
      kind: "subtitles",
      srclang: lang_code,
      label: language,
      mode: "sho…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by elieobeid7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
needs: triage This issue needs to be reviewed
2 participants
Converted from issue

This discussion was converted from issue #8772 on June 18, 2024 17:21.