From 737b0b22d1a2cc2fd737b9fa03b20e84de96c606 Mon Sep 17 00:00:00 2001 From: Mark Boas Date: Tue, 2 Aug 2022 15:47:10 +0200 Subject: [PATCH 1/2] update caption.js --- wp-hyperaudio/js/caption.js | 41 +++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/wp-hyperaudio/js/caption.js b/wp-hyperaudio/js/caption.js index 123728c..4b73bb3 100644 --- a/wp-hyperaudio/js/caption.js +++ b/wp-hyperaudio/js/caption.js @@ -1,5 +1,5 @@ /*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */ -/*! Version 2.0.12 */ +/*! Version 2.0.16 */ 'use strict'; var caption = function () { @@ -26,6 +26,13 @@ var caption = function () { var data = {}; data.segments = []; + console.log(words.length); + + console.log(words[0].innerText); + console.log(words[1].innerText); + console.log(words[2].innerText); + console.log(words[3].innerText); + function segmentMeta(speaker, start, duration, chars) { this.speaker = speaker; this.start = start; @@ -65,6 +72,16 @@ var caption = function () { var lastSpeaker = ''; words.forEach(function (word, i) { + + + for (var key in word) { + if (word.hasOwnProperty(key)) { + console.log(key); + } + } + + console.log("word.innerText = "); + console.log(word.innerText); if (thisSegmentMeta === null) { // create segment meta object thisSegmentMeta = new segmentMeta('', null, 0, 0, 0); @@ -107,6 +124,7 @@ var caption = function () { //console.log("thisDuration = " + thisDuration); var thisText = word.innerText; + console.log(thisText); thisWordMeta = new wordMeta(thisStart, thisDuration, thisText); @@ -302,15 +320,19 @@ var caption = function () { var video = document.getElementById(playerId); - video.addEventListener("loadedmetadata", function() { - //var track = document.createElement("track"); - var track = document.getElementById(playerId+'-vtt'); - track.kind = "captions"; - track.label = "English"; - track.srclang = "en"; - track.src = "data:text/vtt,"+encodeURIComponent(captionsVtt); + if (video !== null) { + video.addEventListener("loadedmetadata", function() { + //var track = document.createElement("track"); + var track = document.getElementById(playerId+'-vtt'); + track.kind = "captions"; + track.label = "English"; + track.srclang = "en"; + track.src = "data:text/vtt,"+encodeURIComponent(captionsVtt); + video.textTracks[0].mode = "showing"; + }); + video.textTracks[0].mode = "showing"; - }); + } video.textTracks[0].mode = "showing"; @@ -324,3 +346,4 @@ var caption = function () { return cap; }; + From 2f49d3d4310caca32dcb0c20afb7502c3d2f82b6 Mon Sep 17 00:00:00 2001 From: Mark Boas Date: Tue, 2 Aug 2022 15:50:26 +0200 Subject: [PATCH 2/2] update caption.js - remove console.logs --- wp-hyperaudio/js/caption.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/wp-hyperaudio/js/caption.js b/wp-hyperaudio/js/caption.js index 4b73bb3..0f69da3 100644 --- a/wp-hyperaudio/js/caption.js +++ b/wp-hyperaudio/js/caption.js @@ -26,13 +26,6 @@ var caption = function () { var data = {}; data.segments = []; - console.log(words.length); - - console.log(words[0].innerText); - console.log(words[1].innerText); - console.log(words[2].innerText); - console.log(words[3].innerText); - function segmentMeta(speaker, start, duration, chars) { this.speaker = speaker; this.start = start; @@ -72,16 +65,6 @@ var caption = function () { var lastSpeaker = ''; words.forEach(function (word, i) { - - - for (var key in word) { - if (word.hasOwnProperty(key)) { - console.log(key); - } - } - - console.log("word.innerText = "); - console.log(word.innerText); if (thisSegmentMeta === null) { // create segment meta object thisSegmentMeta = new segmentMeta('', null, 0, 0, 0); @@ -124,7 +107,6 @@ var caption = function () { //console.log("thisDuration = " + thisDuration); var thisText = word.innerText; - console.log(thisText); thisWordMeta = new wordMeta(thisStart, thisDuration, thisText); @@ -346,4 +328,3 @@ var caption = function () { return cap; }; -