From f54924008f98e154ff228b927ee4da52035ed11c Mon Sep 17 00:00:00 2001 From: Tsachi Shlidor Date: Sun, 8 Dec 2024 13:08:33 +0200 Subject: [PATCH] fix: programatic text-tracks in Safari (#747) * fix: programatic text-tracks in Safari * chore: bundlewatch * fix: programatic text-tracks in Safari --- package.json | 2 +- src/config/defaults.js | 5 ++++- src/plugins/chapters/chapters.js | 4 ---- src/plugins/paced-transcript/index.js | 4 ---- src/plugins/srt-text-tracks/srt-text-tracks.js | 6 +----- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 79848f31..d35e5e84 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, { "path": "./dist/cld-video-player.light.min.js", - "maxSize": "131kb" + "maxSize": "135kb" }, { "path": "./lib/cld-video-player.js", diff --git a/src/config/defaults.js b/src/config/defaults.js index 9bc08a32..46d47399 100644 --- a/src/config/defaults.js +++ b/src/config/defaults.js @@ -27,5 +27,8 @@ export default { analytics: false, cloudinaryAnalytics: true, allowUsageReport: true, - playedEventPercents: [25, 50, 75, 100] + playedEventPercents: [25, 50, 75, 100], + html5: { + nativeTextTracks: false + } }; diff --git a/src/plugins/chapters/chapters.js b/src/plugins/chapters/chapters.js index 46bd04d9..4b4c102a 100644 --- a/src/plugins/chapters/chapters.js +++ b/src/plugins/chapters/chapters.js @@ -100,10 +100,6 @@ const ChaptersPlugin = (function () { default: true }); - // required for Safari to display the captions - // https://github.com/videojs/video.js/issues/8519 - await new Promise(resolve => setTimeout(resolve, 100)); - const end = this.player.duration(); Object.entries(this.options).forEach((entry, index, arr) => { const cue = new VTTCue( diff --git a/src/plugins/paced-transcript/index.js b/src/plugins/paced-transcript/index.js index ab4f6c61..045996e0 100644 --- a/src/plugins/paced-transcript/index.js +++ b/src/plugins/paced-transcript/index.js @@ -64,10 +64,6 @@ function pacedTranscript(config) { mode: options.default ? 'showing' : 'disabled' }); - // required for Safari to display the captions - // https://github.com/videojs/video.js/issues/8519 - await new Promise(resolve => setTimeout(resolve, 100)); - captions.forEach(caption => { captionsTrack.track.addCue(new VTTCue(caption.startTime, caption.endTime, caption.text)); }); diff --git a/src/plugins/srt-text-tracks/srt-text-tracks.js b/src/plugins/srt-text-tracks/srt-text-tracks.js index 4859a733..648d9fac 100644 --- a/src/plugins/srt-text-tracks/srt-text-tracks.js +++ b/src/plugins/srt-text-tracks/srt-text-tracks.js @@ -27,10 +27,6 @@ function srtTextTracks(config, player) { mode: config.default ? 'showing' : 'disabled' }); - // required for Safari to display the captions - // https://github.com/videojs/video.js/issues/8519 - await new Promise(resolve => setTimeout(resolve, 100)); - // Add the WebVTT data to the track webvttCues.forEach(cue => { if (cue) { @@ -47,7 +43,7 @@ function srtTextTracks(config, player) { // SRT parser const srt2webvtt = data => { const SRTParser = new srtParser2(); - + const cues = SRTParser.fromSrt(data); return cues.map(cue => ({