From 8a5e758c9ca6a0c52b7c8ea6cb36cc84f404118e Mon Sep 17 00:00:00 2001 From: Mark Boas Date: Thu, 2 Nov 2023 17:54:23 +0000 Subject: [PATCH 1/2] upgrade ha lite and caption js --- wp-hyperaudio/hyperaudio.php | 14 ++++++------- wp-hyperaudio/js/caption.js | 32 +++++++++++++++++++++-------- wp-hyperaudio/js/hyperaudio-lite.js | 8 ++++++-- wp-hyperaudio/readme.txt | 2 +- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/wp-hyperaudio/hyperaudio.php b/wp-hyperaudio/hyperaudio.php index 4e315cc..9511824 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 **/ @@ -226,12 +226,12 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) function hyperaudio_init() { if (!is_admin()) { - wp_enqueue_script('velocity', plugins_url('/js/velocity.js', __FILE__), array(), '1.0.0', false); - wp_enqueue_script('hyperaudio-lite', plugins_url('/js/hyperaudio-lite.js', __FILE__), array(), '1.0.0', false); - wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), array(), '1.0.0', false); - wp_enqueue_script('share-this', plugins_url('/js/share-this.js', __FILE__), array(), '1.0.0', false); - wp_enqueue_script('share-this-twitter', plugins_url('/js/share-this-twitter.js', __FILE__), array(), '1.0.0', false); - wp_enqueue_script('share-this-clipboard', plugins_url('/js/share-this-clipboard.js', __FILE__), array(), '1.0.0', false); + wp_enqueue_script('velocity', plugins_url('/js/velocity.js', __FILE__), false, '1.0.0', false); + wp_enqueue_script('hyperaudio-lite', plugins_url('/js/hyperaudio-lite.js', __FILE__), false, '1.0.0', false); + wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), false, '1.0.0', false); + wp_enqueue_script('share-this', plugins_url('/js/share-this.js', __FILE__), false, '1.0.0', false); + wp_enqueue_script('share-this-twitter', plugins_url('/js/share-this-twitter.js', __FILE__), false, '1.0.0', false); + wp_enqueue_script('share-this-clipboard', plugins_url('/js/share-this-clipboard.js', __FILE__), false, '1.0.0', false); } } 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 { diff --git a/wp-hyperaudio/readme.txt b/wp-hyperaudio/readme.txt index f9194d0..92a556e 100644 --- a/wp-hyperaudio/readme.txt +++ b/wp-hyperaudio/readme.txt @@ -1,5 +1,5 @@ === Hyperaudio === -Contributors: Maboas +Contributors: Maboa Donate link: https://patreon.com/hyperaudio Tags: Podcasts, Captions, Transcripts, Interactive Transcripts, Accessibility, Media, Audio, Video, Subtitles Requires at least: 3.1 From 9b6058d02214bd798f3505266005debfe5942105 Mon Sep 17 00:00:00 2001 From: Mark Boas Date: Thu, 2 Nov 2023 18:21:46 +0000 Subject: [PATCH 2/2] deal with regressions --- wp-hyperaudio/hyperaudio.php | 12 ++++++------ wp-hyperaudio/readme.txt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-hyperaudio/hyperaudio.php b/wp-hyperaudio/hyperaudio.php index 9511824..d9f2a01 100644 --- a/wp-hyperaudio/hyperaudio.php +++ b/wp-hyperaudio/hyperaudio.php @@ -226,12 +226,12 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag) function hyperaudio_init() { if (!is_admin()) { - wp_enqueue_script('velocity', plugins_url('/js/velocity.js', __FILE__), false, '1.0.0', false); - wp_enqueue_script('hyperaudio-lite', plugins_url('/js/hyperaudio-lite.js', __FILE__), false, '1.0.0', false); - wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), false, '1.0.0', false); - wp_enqueue_script('share-this', plugins_url('/js/share-this.js', __FILE__), false, '1.0.0', false); - wp_enqueue_script('share-this-twitter', plugins_url('/js/share-this-twitter.js', __FILE__), false, '1.0.0', false); - wp_enqueue_script('share-this-clipboard', plugins_url('/js/share-this-clipboard.js', __FILE__), false, '1.0.0', false); + wp_enqueue_script('velocity', plugins_url('/js/velocity.js', __FILE__), array(), '1.0.0', false); + wp_enqueue_script('hyperaudio-lite', plugins_url('/js/hyperaudio-lite.js', __FILE__), array(), '1.0.0', false); + wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), array(), '1.0.0', false); + wp_enqueue_script('share-this', plugins_url('/js/share-this.js', __FILE__), array(), '1.0.0', false); + wp_enqueue_script('share-this-twitter', plugins_url('/js/share-this-twitter.js', __FILE__), array(), '1.0.0', false); + wp_enqueue_script('share-this-clipboard', plugins_url('/js/share-this-clipboard.js', __FILE__), array(), '1.0.0', false); } } diff --git a/wp-hyperaudio/readme.txt b/wp-hyperaudio/readme.txt index 92a556e..f9194d0 100644 --- a/wp-hyperaudio/readme.txt +++ b/wp-hyperaudio/readme.txt @@ -1,5 +1,5 @@ === Hyperaudio === -Contributors: Maboa +Contributors: Maboas Donate link: https://patreon.com/hyperaudio Tags: Podcasts, Captions, Transcripts, Interactive Transcripts, Accessibility, Media, Audio, Video, Subtitles Requires at least: 3.1