Skip to content

Commit 8a5e758

Browse files
committed
upgrade ha lite and caption js
1 parent cf8debd commit 8a5e758

4 files changed

Lines changed: 37 additions & 19 deletions

File tree

wp-hyperaudio/hyperaudio.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Hyperaudio Interactive Transcript
44
* Plugin URI: https://hyper.audio
55
* Description: Hyperaudio Interactive Transcript Maker and Player – maximise your audio and video content's accessibility to humans and search engines.
6-
* Version: 1.0.16
6+
* Version: 1.0.14
77
* Author: Mark Boas
88
* Author URI: https://maboa.it
99
**/
@@ -226,12 +226,12 @@ function hyperaudio_shortcode_handler($atts, $transcript, $tag)
226226
function hyperaudio_init()
227227
{
228228
if (!is_admin()) {
229-
wp_enqueue_script('velocity', plugins_url('/js/velocity.js', __FILE__), array(), '1.0.0', false);
230-
wp_enqueue_script('hyperaudio-lite', plugins_url('/js/hyperaudio-lite.js', __FILE__), array(), '1.0.0', false);
231-
wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), array(), '1.0.0', false);
232-
wp_enqueue_script('share-this', plugins_url('/js/share-this.js', __FILE__), array(), '1.0.0', false);
233-
wp_enqueue_script('share-this-twitter', plugins_url('/js/share-this-twitter.js', __FILE__), array(), '1.0.0', false);
234-
wp_enqueue_script('share-this-clipboard', plugins_url('/js/share-this-clipboard.js', __FILE__), array(), '1.0.0', false);
229+
wp_enqueue_script('velocity', plugins_url('/js/velocity.js', __FILE__), false, '1.0.0', false);
230+
wp_enqueue_script('hyperaudio-lite', plugins_url('/js/hyperaudio-lite.js', __FILE__), false, '1.0.0', false);
231+
wp_enqueue_script('caption', plugins_url('/js/caption.js', __FILE__), false, '1.0.0', false);
232+
wp_enqueue_script('share-this', plugins_url('/js/share-this.js', __FILE__), false, '1.0.0', false);
233+
wp_enqueue_script('share-this-twitter', plugins_url('/js/share-this-twitter.js', __FILE__), false, '1.0.0', false);
234+
wp_enqueue_script('share-this-clipboard', plugins_url('/js/share-this-clipboard.js', __FILE__), false, '1.0.0', false);
235235
}
236236
}
237237

wp-hyperaudio/js/caption.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */
2-
/*! Version 2.1.1 (patch) */
2+
/*! Version 2.1.3 patch 2*/
33
'use strict';
44

55
var caption = function () {
@@ -20,7 +20,7 @@ var caption = function () {
2020
return timecode.substring(0,8) + "," + timecode.substring(9,12);
2121
}
2222

23-
cap.init = function (transcriptId, playerId, maxLength, minLength) {
23+
cap.init = function (transcriptId, playerId, maxLength, minLength, label, srclang) {
2424
var transcript = document.getElementById(transcriptId);
2525
var words = transcript.querySelectorAll('[data-m]');
2626
var data = {};
@@ -303,20 +303,33 @@ var caption = function () {
303303
var video = document.getElementById(playerId);
304304

305305
if (video !== null) {
306-
video.addEventListener("loadedmetadata", function() {
306+
video.addEventListener("loadedmetadata", function listener() {
307307
//var track = document.createElement("track");
308308
var track = document.getElementById(playerId+'-vtt');
309309
track.kind = "captions";
310-
track.label = "English";
311-
track.srclang = "en";
310+
311+
if (label !== undefined) {
312+
console.log("setting label as "+label);
313+
track.label = label;
314+
}
315+
316+
if (srclang !== undefined) {
317+
console.log("setting srclang as "+srclang);
318+
track.srclang = srclang;
319+
}
320+
//track.label = "English";
321+
//track.srclang = "en";
312322
track.src = "data:text/vtt,"+encodeURIComponent(captionsVtt);
313323
video.textTracks[0].mode = "showing";
314-
});
324+
video.removeEventListener("loadedmetadata", listener, true);
325+
}, true);
315326

316-
video.textTracks[0].mode = "showing";
327+
if (video.textTracks[0] !== undefined) {
328+
video.textTracks[0].mode = "showing";
329+
}
317330
}
318331

319-
function captionsObj(vtt, srt) {
332+
function captionsObj(vtt, srt, data) {
320333
// clean up – remove any double blank lines
321334
// and blank line at the start of srt
322335

@@ -326,9 +339,10 @@ var caption = function () {
326339

327340
this.vtt = vtt.replaceAll("\n\n\n","\n\n");
328341
this.srt = srt.replaceAll("\n\n\n","\n\n");
342+
this.data = captions;
329343
}
330344

331-
return new captionsObj(captionsVtt, captionsSrt);
345+
return new captionsObj(captionsVtt, captionsSrt, captions);
332346
};
333347

334348
return cap;

wp-hyperaudio/js/hyperaudio-lite.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */
2-
/*! Version 2.1.3 */
2+
/*! Version 2.1.4 */
33

44
'use strict';
55

@@ -177,7 +177,11 @@ const hyperaudioPlayerOptions = {
177177
}
178178

179179
function hyperaudioPlayer(playerType, instance) {
180-
return new playerType(instance);
180+
if (playerType !== null && playerType !== undefined) {
181+
return new playerType(instance);
182+
} else {
183+
alert("data-player-type attribute must be set on player if not native, eg SoundCloud, YouTube, Vimeo, VideoJS")
184+
}
181185
}
182186

183187
class HyperaudioLite {

wp-hyperaudio/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=== Hyperaudio ===
2-
Contributors: Maboas
2+
Contributors: Maboa
33
Donate link: https://patreon.com/hyperaudio
44
Tags: Podcasts, Captions, Transcripts, Interactive Transcripts, Accessibility, Media, Audio, Video, Subtitles
55
Requires at least: 3.1

0 commit comments

Comments
 (0)