Skip to content

Commit

Permalink
Merge pull request #135 from hyperaudio/133-update-libs
Browse files Browse the repository at this point in the history
133 update libs
  • Loading branch information
maboa authored Nov 3, 2023
2 parents cf8debd + 9b6058d commit 12838e0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion wp-hyperaudio/hyperaudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
**/
Expand Down
32 changes: 23 additions & 9 deletions wp-hyperaudio/js/caption.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions wp-hyperaudio/js/hyperaudio-lite.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 12838e0

Please sign in to comment.