@@ -12486,7 +12486,7 @@ if (typeof module !== "undefined" && module.exports) {
1248612486 if (this.currentCaption !== thisCaption) {
1248712487 // it's time to load the new caption into the container div
1248812488 captionText = this.flattenCueForCaption(cues[thisCaption]).replace(
12489- "\n" ,
12489+ /\n/ ,
1249012490 "<br>"
1249112491 );
1249212492
@@ -13013,139 +13013,140 @@ if (typeof module !== "undefined" && module.exports) {
1301313013})(jQuery);
1301413014
1301513015(function ($) {
13016- AblePlayer.prototype.updateMeta = function (time) {
13017- if (this.hasMeta) {
13018- if (this.metaType === 'text') {
13019- this.$metaDiv.show();
13020- this.showMeta(time || this.elapsed);
13021- }
13022- else {
13023- this.showMeta(time || this.elapsed);
13024- }
13025- }
13026- };
13027-
13028- AblePlayer.prototype.showMeta = function(now) {
13029- var tempSelectors, m, thisMeta,
13030- cues, cueText, cueLines, i, line,
13031- showDuration, focusTarget;
13032-
13033- tempSelectors = [];
13034- if (this.meta.length >= 1) {
13035- cues = this.meta;
13036- }
13037- else {
13038- cues = [];
13039- }
13040- for (m = 0; m < cues.length; m++) {
13041- if ((cues[m].start <= now) && (cues[m].end > now)) {
13042- thisMeta = m;
13043- break;
13044- }
13045- }
13046- if (typeof thisMeta !== 'undefined') {
13047- if (this.currentMeta !== thisMeta) {
13048- if (this.metaType === 'text') {
13049- // it's time to load the new metadata cue into the container div
13050- this.$metaDiv.html(this.flattenCueForMeta(cues[thisMeta]).replace('\n', '<br>'));
13051- }
13052- else if (this.metaType === 'selector') {
13053- // it's time to show content referenced by the designated selector(s)
13054- cueText = this.flattenCueForMeta(cues[thisMeta]);
13055- cueLines = cueText.split('\n');
13056- for (i=0; i<cueLines.length; i++) {
13057- line = $.trim(cueLines[i]);
13058- if (line.toLowerCase().trim() === 'pause') {
13059- // don't show big play button when pausing via metadata
13060- this.hideBigPlayButton = true;
13061- this.pauseMedia();
13062- }
13063- else if (line.toLowerCase().substring(0,6) == 'focus:') {
13064- focusTarget = line.substring(6).trim();
13065- if ($(focusTarget).length) {
13066- $(focusTarget).focus();
13067- }
13068- }
13069- else {
13070- if ($(line).length) {
13071- // selector exists
13072- this.currentMeta = thisMeta;
13073- showDuration = parseInt($(line).attr('data-duration'));
13074- if (typeof showDuration !== 'undefined' && !isNaN(showDuration)) {
13075- $(line).show().delay(showDuration).fadeOut();
13076- }
13077- else {
13078- // no duration specified. Just show the element until end time specified in VTT file
13079- $(line).show();
13080- }
13081- // add to array of visible selectors so it can be hidden at end time
13082- this.visibleSelectors.push(line);
13083- tempSelectors.push(line);
13084-
13085- }
13086- }
13087- }
13088- // now step through this.visibleSelectors and remove anything that's stale
13089- if (this.visibleSelectors && this.visibleSelectors.length) {
13090- if (this.visibleSelectors.length !== tempSelectors.length) {
13091- for (i=this.visibleSelectors.length-1; i>=0; i--) {
13092- if ($.inArray(this.visibleSelectors[i],tempSelectors) == -1) {
13093- $(this.visibleSelectors[i]).hide();
13094- this.visibleSelectors.splice(i,1);
13095- }
13096- }
13097- }
13098- }
13016+ AblePlayer.prototype.updateMeta = function (time) {
13017+ if (this.hasMeta) {
13018+ if (this.metaType === "text") {
13019+ this.$metaDiv.show();
13020+ this.showMeta(time || this.elapsed);
13021+ } else {
13022+ this.showMeta(time || this.elapsed);
13023+ }
13024+ }
13025+ };
1309913026
13100- }
13101- }
13102- }
13103- else {
13104- // there is currently no metadata. Empty stale content
13105- if (typeof this.$metaDiv !== 'undefined') {
13106- this.$metaDiv.html('');
13107- }
13108- if (this.visibleSelectors && this.visibleSelectors.length) {
13109- for (i=0; i<this.visibleSelectors.length; i++) {
13110- $(this.visibleSelectors[i]).hide();
13111- }
13112- // reset array
13113- this.visibleSelectors = [];
13114- }
13115- this.currentMeta = -1;
13116- }
13117- };
13027+ AblePlayer.prototype.showMeta = function (now) {
13028+ var tempSelectors,
13029+ m,
13030+ thisMeta,
13031+ cues,
13032+ cueText,
13033+ cueLines,
13034+ i,
13035+ line,
13036+ showDuration,
13037+ focusTarget;
1311813038
13119- // Takes a cue and returns the metadata text to display for it.
13120- AblePlayer.prototype.flattenCueForMeta = function (cue) {
13121- var result = [];
13039+ tempSelectors = [];
13040+ if (this.meta.length >= 1) {
13041+ cues = this.meta;
13042+ } else {
13043+ cues = [];
13044+ }
13045+ for (m = 0; m < cues.length; m++) {
13046+ if (cues[m].start <= now && cues[m].end > now) {
13047+ thisMeta = m;
13048+ break;
13049+ }
13050+ }
13051+ if (typeof thisMeta !== "undefined") {
13052+ if (this.currentMeta !== thisMeta) {
13053+ if (this.metaType === "text") {
13054+ // it's time to load the new metadata cue into the container div
13055+ this.$metaDiv.html(
13056+ this.flattenCueForMeta(cues[thisMeta]).replace(/\n/, "<br>")
13057+ );
13058+ } else if (this.metaType === "selector") {
13059+ // it's time to show content referenced by the designated selector(s)
13060+ cueText = this.flattenCueForMeta(cues[thisMeta]);
13061+ cueLines = cueText.split("\n");
13062+ for (i = 0; i < cueLines.length; i++) {
13063+ line = $.trim(cueLines[i]);
13064+ if (line.toLowerCase().trim() === "pause") {
13065+ // don't show big play button when pausing via metadata
13066+ this.hideBigPlayButton = true;
13067+ this.pauseMedia();
13068+ } else if (line.toLowerCase().substring(0, 6) == "focus:") {
13069+ focusTarget = line.substring(6).trim();
13070+ if ($(focusTarget).length) {
13071+ $(focusTarget).focus();
13072+ }
13073+ } else {
13074+ if ($(line).length) {
13075+ // selector exists
13076+ this.currentMeta = thisMeta;
13077+ showDuration = parseInt($(line).attr("data-duration"));
13078+ if (
13079+ typeof showDuration !== "undefined" &&
13080+ !isNaN(showDuration)
13081+ ) {
13082+ $(line).show().delay(showDuration).fadeOut();
13083+ } else {
13084+ // no duration specified. Just show the element until end time specified in VTT file
13085+ $(line).show();
13086+ }
13087+ // add to array of visible selectors so it can be hidden at end time
13088+ this.visibleSelectors.push(line);
13089+ tempSelectors.push(line);
13090+ }
13091+ }
13092+ }
13093+ // now step through this.visibleSelectors and remove anything that's stale
13094+ if (this.visibleSelectors && this.visibleSelectors.length) {
13095+ if (this.visibleSelectors.length !== tempSelectors.length) {
13096+ for (i = this.visibleSelectors.length - 1; i >= 0; i--) {
13097+ if ($.inArray(this.visibleSelectors[i], tempSelectors) == -1) {
13098+ $(this.visibleSelectors[i]).hide();
13099+ this.visibleSelectors.splice(i, 1);
13100+ }
13101+ }
13102+ }
13103+ }
13104+ }
13105+ }
13106+ } else {
13107+ // there is currently no metadata. Empty stale content
13108+ if (typeof this.$metaDiv !== "undefined") {
13109+ this.$metaDiv.html("");
13110+ }
13111+ if (this.visibleSelectors && this.visibleSelectors.length) {
13112+ for (i = 0; i < this.visibleSelectors.length; i++) {
13113+ $(this.visibleSelectors[i]).hide();
13114+ }
13115+ // reset array
13116+ this.visibleSelectors = [];
13117+ }
13118+ this.currentMeta = -1;
13119+ }
13120+ };
1312213121
13123- var flattenComponent = function (component) {
13124- var result = [], ii;
13125- if (component.type === 'string') {
13126- result.push(component.value);
13127- }
13128- else if (component.type === 'v') {
13129- result.push('[' + component.value + ']');
13130- for (ii = 0; ii < component.children.length; ii++) {
13131- result.push(flattenComponent(component.children[ii]));
13132- }
13133- }
13134- else {
13135- for (ii = 0; ii < component.children.length; ii++) {
13136- result.push(flattenComponent(component.children[ii]));
13137- }
13138- }
13139- return result.join('');
13140- }
13122+ // Takes a cue and returns the metadata text to display for it.
13123+ AblePlayer.prototype.flattenCueForMeta = function (cue) {
13124+ var result = [];
1314113125
13142- for (var ii = 0; ii < cue.components.children.length; ii++) {
13143- result.push(flattenComponent(cue.components.children[ii]));
13144- }
13126+ var flattenComponent = function (component) {
13127+ var result = [],
13128+ ii;
13129+ if (component.type === "string") {
13130+ result.push(component.value);
13131+ } else if (component.type === "v") {
13132+ result.push("[" + component.value + "]");
13133+ for (ii = 0; ii < component.children.length; ii++) {
13134+ result.push(flattenComponent(component.children[ii]));
13135+ }
13136+ } else {
13137+ for (ii = 0; ii < component.children.length; ii++) {
13138+ result.push(flattenComponent(component.children[ii]));
13139+ }
13140+ }
13141+ return result.join("");
13142+ };
1314513143
13146- return result.join('');
13147- };
13144+ for (var ii = 0; ii < cue.components.children.length; ii++) {
13145+ result.push(flattenComponent(cue.components.children[ii]));
13146+ }
1314813147
13148+ return result.join("");
13149+ };
1314913150})(jQuery);
1315013151
1315113152(function ($) {
@@ -13780,7 +13781,7 @@ if (typeof module !== "undefined" && module.exports) {
1378013781 if (typeof result === "string") {
1378113782 if (thisObj.lyricsMode) {
1378213783 // add <br> BETWEEN each caption and WITHIN each caption (if payload includes "\n")
13783- result = result.replace("\n" , "<br>") + "<br>";
13784+ result = result.replace(/\n/ , "<br>") + "<br>";
1378413785 } else {
1378513786 // just add a space between captions
1378613787 result += " ";
0 commit comments