mirror of
https://github.com/zoriya/react-native-video.git
synced 2025-12-06 07:16:12 +00:00
wip: Add text track handling
This commit is contained in:
@@ -68,7 +68,12 @@ class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
|
||||
|
||||
constructor(source: VideoSource | VideoConfig | VideoPlayerSource) {
|
||||
const video = document.createElement("video");
|
||||
const player = videojs(video, { qualityLevels: true });
|
||||
const player = videojs(video, {
|
||||
qualityLevels: true,
|
||||
html5: {
|
||||
preloadTextTracks: false,
|
||||
},
|
||||
});
|
||||
|
||||
super(new WebEventEmiter(player));
|
||||
|
||||
@@ -286,6 +291,16 @@ class VideoPlayer extends VideoPlayerEvents implements VideoPlayerBase {
|
||||
});
|
||||
if (this.mediaSession.enabled)
|
||||
this.mediaSession.updateMediaSession(source.metadata);
|
||||
|
||||
for (const sub of source.externalSubtitles ?? []) {
|
||||
this.player.addRemoteTextTrack({
|
||||
kind: "subtitles",
|
||||
label: sub.label,
|
||||
src: sub.uri,
|
||||
srclang: sub.language,
|
||||
});
|
||||
}
|
||||
|
||||
if (source.initializeOnCreation) await this.preload();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user