From 44283b6d39b015974f03c0e2e507d3c013f02bf4 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 25 Apr 2025 17:15:59 +0200 Subject: [PATCH] wait #7259 @1 --- js/libs/fluidbook/fluidbook.video.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index 283ad2e1..21e6cb48 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -104,6 +104,7 @@ FluidbookVideo.prototype = { var id = $(e).data('id'), backgroundColor = $(e).data('backgroundcolor'), width = parseFloat($(e).data('width')), height = parseFloat($(e).data('height')), name = $(e).data('name'), controls = parseInt($(e).data('controls')) == 1, loop = parseInt($(e).data('loop')) == 1, + cc = parseInt($(e).data('cc')) == 1, sound = parseInt($(e).data('sound')) == 1, autoplay = parseInt($(e).data('autoplay')) == 1, nativeAutoplay = !autoplay && parseInt($(e).data('nativeautoplay')) == 1, repeat = parseInt($(e).data('repeat')), statsName = $(e).data('stats-name'), @@ -211,6 +212,7 @@ FluidbookVideo.prototype = { } if (tracks) { + let defaultTrack = true; for (var i = 0; i < tracks.length; i++) { var track = tracks[i]; if (!track.file) { @@ -224,13 +226,14 @@ FluidbookVideo.prototype = { if (track.lang) { html += ' srclang="' + track.lang + '"'; } - html += ' default>'; + if (defaultTrack) { + html += ' default'; + defaultTrack = false; + } + html += '>'; } } html += ''; - - console.log(html); - $(e).html(html); let playEventSent = false; @@ -243,7 +246,22 @@ FluidbookVideo.prototype = { } player = videojs(id, setup); + player.ready(function () { + + // Hide CC if disabled in video settings + console.log('cc', cc); + if (!cc) { + console.log('cc disabled'); + var tracks = player.textTracks(); + console.log(tracks); + + for (var i = 0; i < tracks.length; i++) { + var track = tracks[i]; + track.mode = 'hidden'; + } + } + $this.fluidbook.stats.trackEvent(statsType, 'show', statsName); $this.resizeControls(); // Make sure player controls are the right size @@ -321,6 +339,7 @@ FluidbookVideo.prototype = { player.play(); // Start player to go to current position - necessary even if it will be paused immediately + if (settings.paused) { player.pause(); player.one('play', function () { -- 2.39.5