diff --git a/wp-hyperaudio/hyperaudio.php b/wp-hyperaudio/hyperaudio.php index 4e315cc..d9f2a01 100644 --- a/wp-hyperaudio/hyperaudio.php +++ b/wp-hyperaudio/hyperaudio.php @@ -3,7 +3,7 @@ * Plugin Name: Hyperaudio Interactive Transcript * Plugin URI: https://hyper.audio * Description: Hyperaudio Interactive Transcript Maker and Player – maximise your audio and video content's accessibility to humans and search engines. -* Version: 1.0.16 +* Version: 1.0.14 * Author: Mark Boas * Author URI: https://maboa.it **/ diff --git a/wp-hyperaudio/js/caption.js b/wp-hyperaudio/js/caption.js index 84b9a8b..2bee566 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.1.1 (patch) */ +/*! Version 2.1.3 patch 2*/ 'use strict'; var caption = function () { @@ -20,7 +20,7 @@ var caption = function () { return timecode.substring(0,8) + "," + timecode.substring(9,12); } - cap.init = function (transcriptId, playerId, maxLength, minLength) { + cap.init = function (transcriptId, playerId, maxLength, minLength, label, srclang) { var transcript = document.getElementById(transcriptId); var words = transcript.querySelectorAll('[data-m]'); var data = {}; @@ -303,20 +303,33 @@ var caption = function () { var video = document.getElementById(playerId); if (video !== null) { - video.addEventListener("loadedmetadata", function() { + video.addEventListener("loadedmetadata", function listener() { //var track = document.createElement("track"); var track = document.getElementById(playerId+'-vtt'); track.kind = "captions"; - track.label = "English"; - track.srclang = "en"; + + if (label !== undefined) { + console.log("setting label as "+label); + track.label = label; + } + + if (srclang !== undefined) { + console.log("setting srclang as "+srclang); + track.srclang = srclang; + } + //track.label = "English"; + //track.srclang = "en"; track.src = "data:text/vtt,"+encodeURIComponent(captionsVtt); video.textTracks[0].mode = "showing"; - }); + video.removeEventListener("loadedmetadata", listener, true); + }, true); - video.textTracks[0].mode = "showing"; + if (video.textTracks[0] !== undefined) { + video.textTracks[0].mode = "showing"; + } } - function captionsObj(vtt, srt) { + function captionsObj(vtt, srt, data) { // clean up – remove any double blank lines // and blank line at the start of srt @@ -326,9 +339,10 @@ var caption = function () { this.vtt = vtt.replaceAll("\n\n\n","\n\n"); this.srt = srt.replaceAll("\n\n\n","\n\n"); + this.data = captions; } - return new captionsObj(captionsVtt, captionsSrt); + return new captionsObj(captionsVtt, captionsSrt, captions); }; return cap; diff --git a/wp-hyperaudio/js/hyperaudio-lite.js b/wp-hyperaudio/js/hyperaudio-lite.js index 7dca176..a429063 100644 --- a/wp-hyperaudio/js/hyperaudio-lite.js +++ b/wp-hyperaudio/js/hyperaudio-lite.js @@ -1,5 +1,5 @@ /*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */ -/*! Version 2.1.3 */ +/*! Version 2.1.4 */ 'use strict'; @@ -177,7 +177,11 @@ const hyperaudioPlayerOptions = { } function hyperaudioPlayer(playerType, instance) { - return new playerType(instance); + if (playerType !== null && playerType !== undefined) { + return new playerType(instance); + } else { + alert("data-player-type attribute must be set on player if not native, eg SoundCloud, YouTube, Vimeo, VideoJS") + } } class HyperaudioLite {