Created
May 15, 2021 18:23
-
-
Save PatrickKalkman/0ef50b715a31ae0954a452cab2dfaafe to your computer and use it in GitHub Desktop.
Loading and selecting subtitles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let captionUrl = "http://amssamples.streaming.mediaservices.windows.net/bc57e088-27ec-44e0-ac20-a85ccbcd50da/TOS-en.vtt"; | |
this.player | |
.load(videoUrl) | |
.then(() => { | |
this.player.addTextTrackAsync(captionUrl, "en", "subtitle", 'text/vtt').then(() => {{ | |
const textTracks = this.player.getTextTracks(); | |
if (textTracks.length > 0) { | |
this.player.setTextTrackVisibility(true); | |
this.player.selectTextTrack(textTracks[0]); | |
} | |
this.videoElement?.play(); | |
}}); | |
}) | |
.catch((e: any) => { | |
console.error(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment