diff --git a/README.markdown b/README.markdown index f2efc37..b5c2129 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,7 @@ Captionator =========== -**Simple closed-captioning polyfill for HTML5. Just 7KB when gzipped!** +**Simple closed-captioning polyfill for HTML5. Just 8KB when gzipped!** What does Captionator do? _________________________ diff --git a/index.html b/index.html index 579e1a1..f51f34c 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@

HTML5 Video Closed Captioning Example

Media Controls

- + diff --git a/js/captionator-min.js b/js/captionator-min.js index 2053b16..536c112 100644 --- a/js/captionator-min.js +++ b/js/captionator-min.js @@ -1,61 +1,61 @@ -/* - Captionator 0.5b [CaptionCrunch] +/* + Captionator 0.5 [CaptionCrunch] Christopher Giffard, 2011 Share and enjoy https://github.com/cgiffard/Captionator */ -(function(){var t=10,A=16,E=4.5,F=1.5,J=[0,0,0,0.5],B=!1,c={createDOMException:function(b,c,a){try{document.querySelectorAll("div/[]")}catch(f){var d=function(a,b,c){this.code=a;this.message=b;this.name=c};d.prototype=f;return new d(b,c,a)}},compareArray:function(b,c){if(!(b instanceof Array)||!(c instanceof Array))return!1;if(b.length!==c.length)return!1;for(var a in b)if(b.hasOwnProperty(a)&&b[a]!==c[a])return!1;return!0},generateID:function(b){for(var c="",b=b?b:10;c.length0&&a>c.TextTrack.OFF&&this.loadTrack(this.src,null);this.readyState===c.TextTrack.LOADED&&c.rebuildCaptions(this.videoNode);if((a===c.TextTrack.OFF||a===c.TextTrack.HIDDEN)&&this.videoNode.containerObject)try{this.videoNode.containerObject.parentNode.removeChild(this.videoNode.containerObject)}catch(b){}if(a=== +(function(){var x=10,y=16,A=4.5,B=1.5,E=[0,0,0,0.5],F=!1,c={createDOMException:function(b,c,a){try{document.querySelectorAll("div/[]")}catch(f){var d=function(a,b,c){this.code=a;this.message=b;this.name=c};d.prototype=f;return new d(b,c,a)}},compareArray:function(b,c){if(!(b instanceof Array)||!(c instanceof Array))return!1;if(b.length!==c.length)return!1;for(var a in b)if(b.hasOwnProperty(a)&&b[a]!==c[a])return!1;return!0},generateID:function(b){for(var c="",b=b?b:10;c.length0&&a>c.TextTrack.OFF&&this.loadTrack(this.src,null);this.readyState===c.TextTrack.LOADED&&c.rebuildCaptions(this.videoNode);if((a===c.TextTrack.OFF||a===c.TextTrack.HIDDEN)&&this.videoNode.containerObject)try{this.videoNode.containerObject.parentNode.removeChild(this.videoNode.containerObject)}catch(b){}if(a=== c.TextTrack.OFF)this.cues.length=0,this.readyState=c.TextTrack.NONE}}else throw Error("Illegal mode value for track: "+a);};this.getDefault=function(){return this.internalDefault};Object.prototype.__defineGetter__?(this.__defineGetter__("mode",this.getMode),this.__defineSetter__("mode",this.setMode),this.__defineGetter__("default",this.getDefault)):Object.defineProperty&&(Object.defineProperty(this,"mode",{get:this.getMode,set:this.setMode}),Object.defineProperty(this,"default",{get:this.getDefault})); -this.loadTrack=function(a,b){var g,h=new XMLHttpRequest;if(this.readyState===c.TextTrack.LOADED)b instanceof Function&&b(g);else{this.src=a;this.readyState=c.TextTrack.LOADING;var e=this;h.open("GET",a,!0);h.onreadystatechange=function(){if(h.readyState===4)if(h.status===200){var a=e.videoNode._captionatorOptions||{};if(e.kind==="metadata")a.processCueHTML=!1,a.sanitiseCueHTML=!1;g=c.parseCaptions(h.responseText,a);e.readyState=c.TextTrack.LOADED;e.cues.loadCues(g);c.rebuildCaptions(e.videoNode); -e.onload.call(this);b instanceof Function&&b.call(e,g)}else e.readyState=c.TextTrack.ERROR,e.onerror()};try{h.send(null)}catch(d){e.readyState=c.TextTrack.ERROR,e.onerror(d)}}};this.addCue=function(a){if(a&&a instanceof c.TextTrackCue)this.cues.addCue(a);else throw Error("The argument is null or not an instance of TextTrackCue.");};this.removeCue=function(){}};c.TextTrack.NONE=0;c.TextTrack.LOADING=1;c.TextTrack.LOADED=2;c.TextTrack.ERROR=3;c.TextTrack.OFF=0;c.TextTrack.HIDDEN=1;c.TextTrack.SHOWING= +this.loadTrack=function(a,b){var e,h=new XMLHttpRequest;if(this.readyState===c.TextTrack.LOADED)b instanceof Function&&b(e);else{this.src=a;this.readyState=c.TextTrack.LOADING;var i=this;h.open("GET",a,!0);h.onreadystatechange=function(){if(h.readyState===4)if(h.status===200){var a=i.videoNode._captionatorOptions||{};if(i.kind==="metadata")a.processCueHTML=!1,a.sanitiseCueHTML=!1;e=c.parseCaptions(h.responseText,a);i.readyState=c.TextTrack.LOADED;i.cues.loadCues(e);c.rebuildCaptions(i.videoNode); +i.onload.call(this);b instanceof Function&&b.call(i,e)}else i.readyState=c.TextTrack.ERROR,i.onerror()};try{h.send(null)}catch(d){i.readyState=c.TextTrack.ERROR,i.onerror(d)}}};this.addCue=function(a){if(a&&a instanceof c.TextTrackCue)this.cues.addCue(a);else throw Error("The argument is null or not an instance of TextTrackCue.");};this.removeCue=function(){}};c.TextTrack.NONE=0;c.TextTrack.LOADING=1;c.TextTrack.LOADED=2;c.TextTrack.ERROR=3;c.TextTrack.OFF=0;c.TextTrack.HIDDEN=1;c.TextTrack.SHOWING= 2;c.TextTrackCueList=function(a){this.track=a instanceof c.TextTrack?a:null;this.getCueById=function(a){return this.filter(function(b){return b.id===a})[0]};this.loadCues=function(a){for(var b=0;b -0});f instanceof Array&&f.forEach(function(a){var b={D:"direction",L:"linePosition",T:"textPosition",A:"alignment",S:"size"},a=a.split(":");b[a[0]]&&(r[b[a[0]]]=a[1]);b[a[0]]in s&&(s[b[a[0]]]=a[1])})}if(this.linePosition.match(/\%/))this.snapToLines=!1;this.getCueAsSource=function(){return String(this.text)};this.getCueAsHTML=function(){var a=document.createDocumentFragment(),b=document.createElement("div");b.innerHTML=String(this.text);Array.prototype.forEach.call(b.childNodes,function(b){a.appendChild(b.cloneNode(!0))}); +function(a,b,e,d,f,m,j){this.id=a;this.track=j instanceof c.TextTrack?j:null;this.startTime=parseFloat(b);this.endTime=parseFloat(e);this.text=typeof d==="string"||d instanceof c.CaptionatorCueStructure?d:"";this.settings=typeof f==="string"?f:"";this.intSettings={};this.pauseOnExit=!!m;this.wasActive=!1;this.direction="horizontal";this.snapToLines=!0;this.linePosition="auto";this.textPosition=50;this.size=0;this.alignment="middle";if(this.settings.length){var n=this.intSettings,p=this,f=f.split(/\s+/).filter(function(a){return a.length> +0});f instanceof Array&&f.forEach(function(a){var b={D:"direction",L:"linePosition",T:"textPosition",A:"alignment",S:"size"},a=a.split(":");b[a[0]]&&(n[b[a[0]]]=a[1]);b[a[0]]in p&&(p[b[a[0]]]=a[1])})}if(this.linePosition.match(/\%/))this.snapToLines=!1;this.getCueAsSource=function(){return String(this.text)};this.getCueAsHTML=function(){var a=document.createDocumentFragment(),b=document.createElement("div");b.innerHTML=String(this.text);Array.prototype.forEach.call(b.childNodes,function(b){a.appendChild(b.cloneNode(!0))}); return a};this.isActive=function(){var a=0;if(this.track instanceof c.TextTrack&&this.track.mode===c.TextTrack.SHOWING&&this.track.readyState===c.TextTrack.LOADED)try{if(a=this.track.videoNode.currentTime,this.startTime<=a&&this.endTime>=a){if(!this.wasActive)this.wasActive=!0,this.onenter();return!0}}catch(b){return!1}if(this.wasActive)this.wasActive=!1,this.onexit();return!1};Object.prototype.__defineGetter__?this.__defineGetter__("active",this.isActive):Object.defineProperty&&Object.defineProperty(this, -"active",{get:this.isActive});this.toString=function(){return"TextTrackCue:"+this.id+"\n"+String(this.text)};this.onenter=function(){};this.onexit=function(){}};c.MediaTrack=function(a,b,e,d,f,o){var p=function(a){return a.filter(function(a){try{var b=document.createElement(a.getAttribute("type").split("/").shift());return!(!b.canPlayType||!b.canPlayType(a.getAttribute("type")).replace(/no/,""))}catch(c){return!1}}).shift().getAttribute("src")};this.onload=function(){};this.onerror=function(){};this.id= -a||"";this.internalMode=this.internalMode=c.TextTrack.OFF;this.mediaElement=null;this.kind=b||"audiodescription";this.label=e||"";this.language=d||"";this.readyState=c.TextTrack.NONE;this.type=o||"x/unknown";this.mediaType=null;this.src="";if(typeof f==="string")this.src=f;else if(f instanceof NodeList)this.src=p(f);if(this.type.match(/^video\//))this.mediaType="video";else if(this.type.match(/^audio\//))this.mediaType="audio";this.getMode=function(){return this.internalMode};this.setMode=function(a){if([c.TextTrack.OFF, +"active",{get:this.isActive});this.toString=function(){return"TextTrackCue:"+this.id+"\n"+String(this.text)};this.onenter=function(){};this.onexit=function(){}};c.MediaTrack=function(a,b,e,d,f,m){var j=function(a){return a.filter(function(a){try{var b=document.createElement(a.getAttribute("type").split("/").shift());return!(!b.canPlayType||!b.canPlayType(a.getAttribute("type")).replace(/no/,""))}catch(c){return!1}}).shift().getAttribute("src")};this.onload=function(){};this.onerror=function(){};this.id= +a||"";this.internalMode=this.internalMode=c.TextTrack.OFF;this.mediaElement=null;this.kind=b||"audiodescription";this.label=e||"";this.language=d||"";this.readyState=c.TextTrack.NONE;this.type=m||"x/unknown";this.mediaType=null;this.src="";if(typeof f==="string")this.src=f;else if(f instanceof NodeList)this.src=j(f);if(this.type.match(/^video\//))this.mediaType="video";else if(this.type.match(/^audio\//))this.mediaType="audio";this.getMode=function(){return this.internalMode};this.setMode=function(a){if([c.TextTrack.OFF, c.TextTrack.HIDDEN,c.TextTrack.SHOWING].indexOf(a)!==-1){if(a!==this.internalMode)this.internalMode=a,a===c.TextTrack.HIDDEN&&!this.mediaElement&&this.buildMediaElement(),a===c.TextTrack.SHOWING&&this.showMediaElement(),(a===c.TextTrack.OFF||a===c.TextTrack.HIDDEN)&&this.hideMediaElement()}else throw Error("Illegal mode value for track.");};Object.prototype.__defineGetter__?(this.__defineGetter__("mode",this.getMode),this.__defineSetter__("mode",this.setMode)):Object.defineProperty&&Object.defineProperty(this, "mode",{get:this.getMode,set:this.setMode});this.hideMediaElement=function(){if(this.mediaElement&&(this.mediaElement.paused||this.mediaElement.pause(),this.mediaElement instanceof HTMLVideoElement))this.mediaElement.style.display="none"};this.showMediaElement=function(){if(this.mediaElement){if(this.mediaElement.parentNode||document.body.appendChild(this.mediaElement),this.mediaElement instanceof HTMLVideoElement)this.mediaElement.style.display="block"}else this.buildMediaElement(),document.body.appendChild(this.mediaElement)}; this.buildMediaElement=function(){try{if(this.type.match(/^video\//))this.mediaElement=document.createElement("video"),this.mediaElement.className="captionator-mediaElement-"+this.kind,c.styleNode(this.mediaElement,this.kind,this.videoNode);else if(this.type.match(/^audio\//))this.mediaElement=new Audio;this.mediaElement.type=this.type;this.mediaElement.src=this.src;this.mediaElement.load();this.mediaElement.trackObject=this;this.readyState=c.TextTrack.LOADING;var a=this.mediaElement;this.mediaElement.addEventListener("progress", function(){a.trackObject.readyState=c.TextTrack.LOADING},!1);this.mediaElement.addEventListener("canplaythrough",function(){a.trackObject.readyState=c.TextTrack.LOADED;a.trackObject.onload.call(a.trackObject)},!1);this.mediaElement.addEventListener("error",function(b){a.trackObject.readyState=c.TextTrack.ERROR;a.trackObject.mode=c.TextTrack.OFF;a.trackObject.mediaElement=null;a.trackObject.onerror.call(a.trackObject,b)},!1)}catch(b){this.readyState=c.TextTrack.ERROR,this.mode=c.TextTrack.OFF,this.mediaElement= -null,this.onerror&&this.onerror.apply(this,b)}}};c.CaptionatorCueStructure=function(a,b){var c=this;this.isTimeDependent=!1;this.cueSource=a;this.options=b;this.processedCue=null;this.toString=function(e){if(b.processCueHTML!==!1){var d=function(a,b){if(c.processedCue===null){var f="",g,h;for(g in a)if(g.match(/^\d+$/)&&a.hasOwnProperty(g))if(h=a[g],h instanceof Object&&h.children&&h.children.length)if(h.token==="v")f+=''+d(h.children,b+1)+"";else if(h.token==="c")f+=""+d(h.children,b+1)+"";else if(h.timeIn>0){if(e===null||e===void 0||e>0&&e>=h.timeIn)f+=""+d(h.children,b+1)+""}else f+=h.rawToken+d(h.children,b+1)+"";else if(h instanceof String||typeof h==="string"|| -typeof h==="number")f+=h;if(!c.isTimeDependent&&b===0)c.processedCue=f;return f}else return c.processedCue};return d(this,0)}else return a}};c.CaptionatorCueStructure.prototype=[];if(a.exportObjects)window.TextTrack=c.TextTrack,window.TextTrackCueList=c.TextTrackCueList,window.ActiveTextTrackCueList=c.ActiveTextTrackCueList,window.TextTrackCue=c.TextTrackCue,window.MediaTrack=c.MediaTrack;B=!0}[].slice.call(document.getElementsByTagName("video"),0).forEach(function(a){a.addTextTrack=function(b,e, -d,f,o,p,r){var s="subtitles,captions,descriptions,captions,metadata,karaoke,lyrics,tickertext,audiodescription,commentary,alternate,signlanguage".split(","),h=s.slice(0,7),b=typeof b==="string"?b:"",d=typeof d==="string"?d:"",f=typeof f==="string"?f:"",r=typeof r==="boolean"?r:!1;if(!s.filter(function(a){return e===a?!0:!1}).length)throw c.createDOMException(12,"DOMException 12: SYNTAX_ERR: You must use a valid kind when creating a TimedTextTrack.","SYNTAX_ERR");if(h.filter(function(a){return e=== -a?!0:!1}).length)if(b=new c.TextTrack(b,e,d,f,o,null)){if(!(a.tracks instanceof Array))a.tracks=[];a.tracks.push(b);return b}else return!1;else if(b=new c.MediaTrack(b,e,d,f,o,p,r)){if(!(a.mediaTracks instanceof Array))a.mediaTracks=[];a.mediaTracks.push(b);return b}else return!1}});if(!b||b===!1||b===void 0||b===null)f=[].slice.call(document.getElementsByTagName("video"),0);else if(b instanceof Array)for(d=0;d'+f(g.children,b+1)+"";else if(g.token==="c")d+=""+f(g.children,b+1)+"";else if(g.timeIn>0){if(e===null||e===void 0||e>0&&e>=g.timeIn)d+=""+f(g.children,b+1)+""}else d+=g.rawToken+f(g.children,b+1)+"";else if(g instanceof String||typeof g==="string"|| +typeof g==="number")d+=g;if(!c.isTimeDependent&&b===0)c.processedCue=d;return d}else return c.processedCue};return f(this,0)}else return a}};c.CaptionatorCueStructure.prototype=[];if(a.exportObjects)window.TextTrack=c.TextTrack,window.TextTrackCueList=c.TextTrackCueList,window.ActiveTextTrackCueList=c.ActiveTextTrackCueList,window.TextTrackCue=c.TextTrackCue,window.MediaTrack=c.MediaTrack;F=!0}[].slice.call(document.getElementsByTagName("video"),0).forEach(function(a){a.addTextTrack=function(b,e, +d,f,m,j,n){var p="subtitles,captions,descriptions,captions,metadata,karaoke,lyrics,tickertext,audiodescription,commentary,alternate,signlanguage".split(","),w=p.slice(0,7),b=typeof b==="string"?b:"",d=typeof d==="string"?d:"",f=typeof f==="string"?f:"",n=typeof n==="boolean"?n:!1;if(!p.filter(function(a){return e===a?!0:!1}).length)throw c.createDOMException(12,"DOMException 12: SYNTAX_ERR: You must use a valid kind when creating a TimedTextTrack.","SYNTAX_ERR");if(w.filter(function(a){return e=== +a?!0:!1}).length)if(b=new c.TextTrack(b,e,d,f,m,null)){if(!(a.tracks instanceof Array))a.tracks=[];a.tracks.push(b);return b}else return!1;else if(b=new c.MediaTrack(b,e,d,f,m,j,n)){if(!(a.mediaTracks instanceof Array))a.mediaTracks=[];a.mediaTracks.push(b);return b}else return!1}});if(!b||b===!1||b===void 0||b===null)f=[].slice.call(document.getElementsByTagName("video"),0);else if(b instanceof Array)for(d=0;d0?d.querySelectorAll("source"):d.getAttribute("src"),g=b.addTextTrack(d.getAttribute("id")||c.generateID(),d.getAttribute("kind"),d.getAttribute("label"),d.getAttribute("srclang").split("-")[0],g,d.getAttribute("type"),d.hasAttribute("default"));d.track=g;g.trackNode=d;g.videoNode=b;f.push(g);var k=!1;if((g.kind==="subtitles"||g.kind==="captions")&& -e===g.language&&a.enableCaptionsByDefault)f.filter(function(a){return(a.kind==="captions"||a.kind==="subtitles")&&e===a.language&&a.mode===c.TextTrack.SHOWING?!0:!1}).length||(k=!0);g.kind==="chapters"&&e===g.language&&(f.filter(function(a){return a.kind==="chapters"&&a.mode===c.TextTrack.SHOWING?!0:!1}).length||(k=!0));g.kind==="descriptions"&&a.enableDescriptionsByDefault===!0&&e===g.language&&(f.filter(function(a){return a.kind==="descriptions"&&a.mode===c.TextTrack.SHOWING?!0:!1}).length||(k= -!0));k===!0&&f.forEach(function(a){if(a.trackNode.hasAttribute("default")&&a.mode===c.TextTrack.SHOWING)a.mode=c.TextTrack.HIDDEN});if(d.hasAttribute("default")&&!f.filter(function(a){return a.trackNode.hasAttribute("default")&&a.trackNode!==d?!0:!1}).length)k=!0,g.internalDefault=!0;if(k===!0)g.mode=c.TextTrack.SHOWING});b.addEventListener("timeupdate",function(b){b=b.target;try{b.tracks.forEach(function(a){a.activeCues.refreshCues.apply(a.activeCues)})}catch(e){}a.renderer instanceof Function?a.renderer.call(c, -b):c.rebuildCaptions(b);c.synchroniseMediaElements(b)},!1);b.addEventListener("play",function(){c.synchroniseMediaElements(b)},!1);b.addEventListener("pause",function(){c.synchroniseMediaElements(b)},!1)}return b},rebuildCaptions:function(b){var e=b.currentTime,a=[],f=!1,d=[],l=[];(b.tracks||[]).forEach(function(b){b.mode===c.TextTrack.SHOWING&&b.readyState===c.TextTrack.LOADED&&(l=[].slice.call(b.activeCues,0),l=l.sort(function(a,b){return a.startTime>b.startTime?-1:1}),a=a.concat(l))});d=a.map(function(a){return a.track.id+ -"."+a.id+":"+a.text.toString(e).length});if(f=!c.compareArray(d,b._captionator_previousActiveCues))b._captionator_availableCueArea=null,b._captionator_previousActiveCues=d,c.styleCueCanvas(b),b._containerObject.innerHTML="",a.forEach(function(a){var d=document.createElement("div");d.id=String(a.id).length?a.id:c.generateID();d.className="captionator-cue";d.innerHTML=a.text.toString(e);b._containerObject.appendChild(d);c.styleCue(d,a,b)})},synchroniseMediaElements:function(b){var e=function(a,b){try{b.seeking&& -a.pause();if(a.currentTimeb.currentTime+0.5)a.currentTime=b.currentTime;a.paused&&!b.paused?a.play():!a.paused&&b.paused&&a.pause()}catch(c){}};(b.mediaTracks||[]).forEach(function(a){a.mode===c.TextTrack.SHOWING&&a.readyState>=c.TextTrack.LOADING&&e(a.mediaElement,b)});b.id&&[].slice.call(document.body.querySelectorAll("*[syncMaster="+b.id+"]"),0).forEach(function(a){(a.tagName.toLowerCase()==="video"||a.tagName.toLowerCase()==="audio")&&e(a,b)})},getNodeMetrics:function(b){for(var c= -window.getComputedStyle(b,null),a=b,f=b.offsetTop,d=b.offsetLeft,l=b,g=0,k=0,l=parseInt(c.getPropertyValue("width"),10),g=parseInt(c.getPropertyValue("height"),10);a=a.offsetParent;)f+=a.offsetTop,d+=a.offsetLeft;if(b.hasAttribute("controls"))b=navigator.userAgent.toLowerCase(),b.indexOf("chrome")!==-1?k=32:b.indexOf("opera")!==-1?k=25:b.indexOf("firefox")!==-1?k=28:b.indexOf("ie 9")!==-1||b.indexOf("ipad")!==-1?k=44:b.indexOf("safari")!==-1&&(k=25);else if(b._captionatorOptions)b=b._captionatorOptions, -b.controlHeight&&(k=parseInt(b.controlHeight,10));return{left:d,top:f,width:l,height:g,controlHeight:k}},applyStyles:function(b,c){for(var a in c)({}).hasOwnProperty.call(c,a)&&(b.style[a]=c[a])},checkDirection:function(b){var c=RegExp("^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff]");return RegExp("^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]").test(b)? -"rtl":c.test(b)?"ltr":""},styleCue:function(b,e,a){var f=0,d=0,l=0,g=0,k,v,G=0,o=0,p,r,s,h,q,m,C=0,w=k=d=0,i=0,H=0,x=0,y,D,z=0,i=a._captionatorOptions||{},j,B=function(a){var b=function(a){return!!a.length},d,e,f,h,g=0,i=function(a){g++;c.applyStyles(a,{display:"block",lineHeight:"auto",height:p+"px",width:m+"px",textAlign:"center"})};for(d in a.childNodes)if(a.childNodes.hasOwnProperty(d))e=a.childNodes[d],e.nodeType===3?(h=document.createDocumentFragment(),f=e.nodeValue,h.appendChild(document.createElement("span")), -h.childNodes[0].innerHTML=""+f.split(/(.)/).filter(b).join("")+"",[].slice.call(h.querySelectorAll("span.captionator-cue-character"),0).forEach(i),e.parentNode.replaceChild(h,e)):a.childNodes[d].nodeType===1&&(g+=B(a.childNodes[d]));return g};j=c.getNodeMetrics(a);if(!a._captionator_availableCueArea)a._captionator_availableCueArea={bottom:j.height-j.controlHeight,right:j.width,top:0,left:0,height:j.height- -j.controlHeight,width:j.width};d=j.height*(E/100)/96*72;d=d>=t?d:t;p=Math.floor(d/72*96);r=Math.floor(d*F);r=r>A?r:A;m=q=Math.ceil(r/72*96);q*Math.floor(j.height/q)=C-1?(z=0,x++):z++}));e.direction==="horizontal"&&(v=c.checkDirection(String(e.text))==="rtl"?{start:"right",middle:"center", -end:"left"}[e.alignment]:{start:"left",middle:"center",end:"right"}[e.alignment]);c.applyStyles(b,{position:"absolute",overflow:"hidden",width:l+"px",height:g+"px",top:d+"px",left:f+"px",padding:o+"px "+G+"px",textAlign:v,backgroundColor:"rgba("+J.join(",")+")",direction:c.checkDirection(String(e.text)),lineHeight:r+"pt",boxSizing:"border-box"});if(e.direction==="vertical"||e.direction==="vertical-lr")f-a._captionator_availableCueArea.left-a._captionator_availableCueArea.left>=a._captionator_availableCueArea.right- -(f+l)?a._captionator_availableCueArea.right=f:a._captionator_availableCueArea.left=f+l,a._captionator_availableCueArea.width=a._captionator_availableCueArea.right-a._captionator_availableCueArea.left;else{if(b.scrollHeight>b.offsetHeight*1.2){if(e.snapToLines){for(v=0;b.scrollHeight>b.offsetHeight*1.2;)g+=q,b.style.height=g+"px",v++;d-=v*q}else v=b.scrollHeight-g,g=b.scrollHeight+j.height*0.01,d-=v,b.style.height=g+"px";b.style.top=d+"px"}d-a._captionator_availableCueArea.top-a._captionator_availableCueArea.top>= -a._captionator_availableCueArea.bottom-(d+g)?a._captionator_availableCueArea.bottom=d:a._captionator_availableCueArea.top=d+g;a._captionator_availableCueArea.height=a._captionator_availableCueArea.bottom-a._captionator_availableCueArea.top}if(i.debugMode){var u,n,I=function(){if(!u)a._captionatorDebugCanvas?(u=a._captionatorDebugCanvas,n=a._captionatorDebugContext):(u=document.createElement("canvas"),u.setAttribute("width",j.width),u.setAttribute("height",j.height-j.controlHeight),document.body.appendChild(u), -c.applyStyles(u,{position:"absolute",top:j.top+"px",left:j.left+"px",width:j.width+"px",height:j.height-j.controlHeight+"px",zIndex:3E3}),n=u.getContext("2d"),a._captionatorDebugCanvas=u,a._captionatorDebugContext=n)};I();u.setAttribute("width",j.width);I();n.fillStyle="rgba(100,100,255,0.5)";n.fillRect(a._captionator_availableCueArea.left,a._captionator_availableCueArea.top,a._captionator_availableCueArea.right,a._captionator_availableCueArea.bottom);n.stroke();(function(){var b;I();n.strokeStyle= -"rgba(255,0,0,0.5)";n.lineWidth=1;n.beginPath();for(b=0;b=0;b--)n.moveTo(j.width-b*m-0.5,-0.5),n.lineTo(j.width-b*m-0.5,j.height);n.closePath();n.stroke();n.beginPath();n.strokeStyle="rgba(255,255,0,0.5)";for(b=0;b<=h;b++)n.moveTo(b*m+0.5,-0.5),n.lineTo(b*m+0.5,j.height);n.stroke();a.linesDrawn=!0})()}},styleCueCanvas:function(b){var e,a,f=b._captionatorOptions instanceof -Object?b._captionatorOptions:{};if(!(b instanceof HTMLVideoElement))throw Error("Cannot style a cue canvas for a non-video node!");if(b._containerObject)a=b._containerObject,e=a.id;if(a)a.parentNode||document.body.appendChild(a);else{a=document.createElement("div");a.className="captionator-cue-canvas";e=c.generateID();a.id=e;if(f.appendCueCanvasTo){var d=null;if(f.appendCueCanvasTo instanceof HTMLElement)d=f.appendCueCanvasTo;else if(typeof f.appendCueCanvasTo==="string")try{var l=document.querySelectorAll(f.appendCueCanvasTo); -if(l.length>0)d=l[0];else throw null;}catch(g){d=document.body,f.appendCueCanvasTo=!1}else d=document.body,f.appendCueCanvasTo=!1;d.appendChild(a)}else document.body.appendChild(a);b._containerObject=a;a.setAttribute("aria-live","polite");a.setAttribute("aria-atomic","true")}String(b.getAttribute("aria-describedby")).indexOf(e)===-1&&(d=b.hasAttribute("aria-describedby")?b.getAttribute("aria-describedby")+" ":"",b.setAttribute("aria-describedby",d+e));d=c.getNodeMetrics(b);b=d.height*(E/100)/96*72; -b=b>=t?b:t;e=Math.floor(b*F);e=e>A?e:A;c.applyStyles(a,{position:"absolute",overflow:"hidden",zIndex:100,height:d.height-d.controlHeight+"px",width:d.width+"px",top:(f.appendCueCanvasTo?0:d.top)+"px",left:(f.appendCueCanvasTo?0:d.left)+"px",color:"white",fontFamily:"Verdana, Helvetica, Arial, sans-serif",fontSize:b+"pt",lineHeight:e+"pt",boxSizing:"border-box"});if(window.navigator.userAgent.toLowerCase().indexOf("chrome/10")>-1)a.style.backgroundColor="rgba(0,0,0,0.01"+Math.random().toString().replace(".", -"")+")"},parseCaptions:function(b,e){var e=e instanceof Object?e:{},a="",f=[],d=/^(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\,(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/,l=/^(\d+)?:?(\d{2}):(\d{2})\.(\d+)\,(\d+)?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/,g=/^(\d{2})?:?(\d{2}):(\d{2})[\.\,](\d+)\s+\-\-\>\s+(\d{2})?:?(\d{2}):(\d{2})[\.\,](\d+)\s*(.*)/,k=/(\d{2})?:?(\d{2}):(\d{2})[\.\,](\d+)/,v=/^([\d\.]+)\s+\+([\d\.]+)\s*(.*)/,t=/^\[(\d{2})?:?(\d{2})\:(\d{2})\.(\d{2})\]\s*(.*?)$/i,o=/^DEFAULT(S)?\s+\-\-\>\s+(.*)/,p=/^STYLE(S)?\s+\-\-\>\s+(.*)/, -r=/^COMMENT(S)?\s+\-\-\>\s+(.*)/;if(b){var s=function(a){var b=new c.CaptionatorCueStructure(a,e),d=[],f,g,i,l=[];i=0;var o=function(a){return!!a.replace(/[^a-z0-9]+/ig,"").length},d=a.split(/(<\/?[^>]+>)/ig).filter(function(a){return!!a.replace(/\s*/ig,"")});i=b;for(f in d)if(d.hasOwnProperty(f))if(g=d[f],g.substr(0,1)==="<")if(g.substr(1,1)==="/"){if(a=g.substr(2).split(/[\s>]+/g)[0],l.length>0){g=0;for(i=l.length-1;i>=0;i--){var p=l[i][l[i].length-1];g=i;if(p.token===a)break}i=l[g];l=l.slice(0, -g)}}else{if(g.substr(1).match(k)||g.match(/^]+>/i)||g.match(/^/)||g.match(/^<(b|i|u|ruby|rt)>/)||e.sanitiseCueHTML!==!1){a={token:g.replace(/[<\/>]+/ig,"").split(/[\s\.]+/)[0],rawToken:g,children:[]};if(a.token==="v")a.voice=g.match(/^]+)>/i)[1];else if(a.token==="c")a.classes=g.replace(/[<\/>\s]+/ig,"").split(/[\.]+/ig).slice(1).filter(o);else if(g=a.rawToken.match(k))b.isTimeDependent=!0,g=g.slice(1),a.timeIn=parseInt((g[0]||0)*3600,10)+parseInt((g[1]||0)*60,10)+ -parseInt(g[2]||0,10)+parseFloat("0."+(g[3]||0));i.push(a);l.push(i);i=a.children}}else e.sanitiseCueHTML!==!1&&(g=g.replace(//g,">").replace(/\&/g,"&")),i.push(g);return b},f=b.replace(/\r\n/g,"\n").replace(/\r/g,"\n");t.exec(b)?(f=f.split(/\n+/g),a="LRC"):f=f.split(/\n\n+/g);return f=f.filter(function(b){return b.match(/^WEBVTT(\s*FILE)?/ig)?(a="WebVTT",!1):b.replace(/\s*/ig,"").length?!0:!1}).map(function(b,f){var m,k,w,i,t,x;if(o.exec(b)||p.exec(b)||r.exec(b))return null; -for(m=a==="LRC"?[b.substr(0,b.indexOf("]")),b.substr(b.indexOf("]")+1)]:b.split(/\n/g);!m[0].replace(/\s+/ig,"").length&&m.length>0;)m.shift();for(x=m[0].match(/^\s*\d+\s*$/ig)?String(m.shift().replace(/\s*/ig,"")):f;00?d.querySelectorAll("source"):d.getAttribute("src"),h=b.addTextTrack(d.getAttribute("id")||c.generateID(),d.getAttribute("kind"),d.getAttribute("label"),d.getAttribute("srclang").split("-")[0],h,d.getAttribute("type"),d.hasAttribute("default"));d.track=h;h.trackNode=d;h.videoNode=b;f.push(h);var i=!1;if((h.kind==="subtitles"||h.kind==="captions")&& +e===h.language&&a.enableCaptionsByDefault)f.filter(function(a){return(a.kind==="captions"||a.kind==="subtitles")&&e===a.language&&a.mode===c.TextTrack.SHOWING?!0:!1}).length||(i=!0);h.kind==="chapters"&&e===h.language&&(f.filter(function(a){return a.kind==="chapters"&&a.mode===c.TextTrack.SHOWING?!0:!1}).length||(i=!0));h.kind==="descriptions"&&a.enableDescriptionsByDefault===!0&&e===h.language&&(f.filter(function(a){return a.kind==="descriptions"&&a.mode===c.TextTrack.SHOWING?!0:!1}).length||(i= +!0));i===!0&&f.forEach(function(a){if(a.trackNode.hasAttribute("default")&&a.mode===c.TextTrack.SHOWING)a.mode=c.TextTrack.HIDDEN});if(d.hasAttribute("default")&&!f.filter(function(a){return a.trackNode.hasAttribute("default")&&a.trackNode!==d?!0:!1}).length)i=!0,h.internalDefault=!0;if(i===!0)h.mode=c.TextTrack.SHOWING});b.addEventListener("timeupdate",function(b){b=b.target;try{b.tracks.forEach(function(a){a.activeCues.refreshCues.apply(a.activeCues)})}catch(e){}a.renderer instanceof Function?a.renderer.call(c, +b):c.rebuildCaptions(b);c.synchroniseMediaElements(b)},!1);window.addEventListener("resize",function(){b._captionator_dirtyBit=!0;c.rebuildCaptions(b)},!1);b.addEventListener("play",function(){c.synchroniseMediaElements(b)},!1);b.addEventListener("pause",function(){c.synchroniseMediaElements(b)},!1)}return b},rebuildCaptions:function(b){var e=b.currentTime,a=[],f=!1,d=[],g=[];(b.tracks||[]).forEach(function(b){b.mode===c.TextTrack.SHOWING&&b.readyState===c.TextTrack.LOADED&&(g=[].slice.call(b.activeCues, +0),g=g.sort(function(a,b){return a.startTime>b.startTime?-1:1}),a=a.concat(g))});d=a.map(function(a){return a.track.id+"."+a.id+":"+a.text.toString(e).length});if((f=!c.compareArray(d,b._captionator_previousActiveCues))||b._captionator_dirtyBit)b._captionator_dirtyBit=!1,b._captionator_availableCueArea=null,b._captionator_previousActiveCues=d,c.styleCueCanvas(b),b._containerObject.innerHTML="",a.forEach(function(a){var d=document.createElement("div");d.id=String(a.id).length?a.id:c.generateID();d.className= +"captionator-cue";d.innerHTML=a.text.toString(e);b._containerObject.appendChild(d);c.styleCue(d,a,b)})},synchroniseMediaElements:function(b){var e=function(a,b){try{b.seeking&&a.pause();if(a.currentTimeb.currentTime+0.5)a.currentTime=b.currentTime;a.paused&&!b.paused?a.play():!a.paused&&b.paused&&a.pause()}catch(c){}};(b.mediaTracks||[]).forEach(function(a){a.mode===c.TextTrack.SHOWING&&a.readyState>=c.TextTrack.LOADING&&e(a.mediaElement,b)});b.id&&[].slice.call(document.body.querySelectorAll("*[syncMaster="+ +b.id+"]"),0).forEach(function(a){(a.tagName.toLowerCase()==="video"||a.tagName.toLowerCase()==="audio")&&e(a,b)})},getNodeMetrics:function(b){for(var c=window.getComputedStyle(b,null),a=b,f=b.offsetTop,d=b.offsetLeft,g=b,h=0,i=0,g=parseInt(c.getPropertyValue("width"),10),h=parseInt(c.getPropertyValue("height"),10);a=a.offsetParent;)f+=a.offsetTop,d+=a.offsetLeft;if(b.hasAttribute("controls"))b=navigator.userAgent.toLowerCase(),b.indexOf("chrome")!==-1?i=32:b.indexOf("opera")!==-1?i=25:b.indexOf("firefox")!== +-1?i=28:b.indexOf("ie 9")!==-1||b.indexOf("ipad")!==-1?i=44:b.indexOf("safari")!==-1&&(i=25);else if(b._captionatorOptions)b=b._captionatorOptions,b.controlHeight&&(i=parseInt(b.controlHeight,10));return{left:d,top:f,width:g,height:h,controlHeight:i}},applyStyles:function(b,c){for(var a in c)({}).hasOwnProperty.call(c,a)&&(b.style[a]=c[a])},checkDirection:function(b){var c=RegExp("^[^\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]*[A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff]"); +return RegExp("^[^A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff]*[\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc]").test(b)?"rtl":c.test(b)?"ltr":""},styleCue:function(b,e,a){var f=0,d=0,g=0,h=0,i,v,s=0,m=0,j,n,p,w,t,z=0,C=i=d=0,k=0,D=0,u=0,l,q,o=0,s=a._captionatorOptions||{},r=50,f=j=0,r=!0,G=function(a){var b=function(a){return!!a.length},d,e,f,g,h=0,i=function(a){h++;c.applyStyles(a,{display:"block",lineHeight:"auto",height:n+"px",width:t+ +"px",textAlign:"center"})};for(d in a.childNodes)if(a.childNodes.hasOwnProperty(d))e=a.childNodes[d],e.nodeType===3?(g=document.createDocumentFragment(),f=e.nodeValue,g.appendChild(document.createElement("span")),g.childNodes[0].innerHTML=""+f.split(/(.)/).filter(b).join("")+"",[].slice.call(g.querySelectorAll("span.captionator-cue-character"),0).forEach(i),e.parentNode.replaceChild(g,e)):a.childNodes[d].nodeType=== +1&&(h+=G(a.childNodes[d]));return h},k=c.getNodeMetrics(a);if(!a._captionator_availableCueArea)a._captionator_availableCueArea={bottom:k.height-k.controlHeight,right:k.width,top:0,left:0,height:k.height-k.controlHeight,width:k.width};e.direction==="horizontal"&&(c.applyStyles(b,{width:"auto",position:"static",display:"inline-block",padding:"1em"}),j=parseInt(b.offsetWidth,10),f=Math.floor(j/a._captionator_availableCueArea.width*100),f=f<=100?f:100);j=k.height*(A/100)/96*72;j=j>=x?j:x;n=Math.floor(j/ +72*96);p=Math.floor(j*B);p=p>y?p:y;t=j=Math.ceil(p/72*96);j*Math.floor(k.height/j)f?i-=r:i=f),g=e.snapToLines===!0?a._captionator_availableCueArea.width* +(i/100):k.width*(i/100),e.textPosition==="auto"?f=(a._captionator_availableCueArea.right-g)/2+a._captionator_availableCueArea.left:(r=parseFloat(String(e.textPosition).replace(/[^\d\.]/ig,"")),f=(a._captionator_availableCueArea.right-g)*(r/100)+a._captionator_availableCueArea.left),e.snapToLines===!0?d=(d-1)*j+a._captionator_availableCueArea.top:(i=k.controlHeight+j+m*2,d=(k.height-i)*(e.linePosition/100))):(d=a._captionator_availableCueArea.top,f=a._captionator_availableCueArea.right-t,g=t,h=a._captionator_availableCueArea.height* +(i/100),d=G(b),i=[].slice.call(b.querySelectorAll("span.captionator-cue-character"),0),z=Math.floor((h-m*2)/n),g=Math.ceil(d/z)*t,C=Math.ceil(d/z),D=(d-z*(C-1))*n,e.snapToLines===!0?f=e.direction==="vertical-lr"?a._captionator_availableCueArea.left:a._captionator_availableCueArea.right-g:(d=g+s*2,f=e.direction==="vertical-lr"?(k.width-d)*(e.linePosition/100):k.width-d-(k.width-d)*(e.linePosition/100)),e.textPosition==="auto"?d=(a._captionator_availableCueArea.bottom-h)/2+a._captionator_availableCueArea.top: +(e.textPosition=parseFloat(String(e.textPosition).replace(/[^\d\.]/ig,"")),d=(a._captionator_availableCueArea.bottom-h)*(e.textPosition/100)+a._captionator_availableCueArea.top),q=l=o=u=0,i.forEach(function(a){l=e.direction==="vertical-lr"?t*u:g-t*(u+1);e.alignment==="start"||e.alignment!=="start"&&u=z-1?(o=0,u++):o++}));e.direction==="horizontal"&& +(v=c.checkDirection(String(e.text))==="rtl"?{start:"right",middle:"center",end:"left"}[e.alignment]:{start:"left",middle:"center",end:"right"}[e.alignment]);c.applyStyles(b,{position:"absolute",overflow:"hidden",width:g+"px",height:h+"px",top:d+"px",left:f+"px",padding:m+"px "+s+"px",textAlign:v,backgroundColor:"rgba("+E.join(",")+")",direction:c.checkDirection(String(e.text)),lineHeight:p+"pt",boxSizing:"border-box"});if(e.direction==="vertical"||e.direction==="vertical-lr")f-a._captionator_availableCueArea.left- +a._captionator_availableCueArea.left>=a._captionator_availableCueArea.right-(f+g)?a._captionator_availableCueArea.right=f:a._captionator_availableCueArea.left=f+g,a._captionator_availableCueArea.width=a._captionator_availableCueArea.right-a._captionator_availableCueArea.left;else{if(b.scrollHeight>b.offsetHeight*1.2){if(e.snapToLines){for(v=0;b.scrollHeight>b.offsetHeight*1.2;)h+=j,b.style.height=h+"px",v++;d-=v*j}else h=b.scrollHeight+m,i=k.controlHeight+h+m*2,d=(k.height-i)*(e.linePosition/100), +b.style.height=h+"px";b.style.top=d+"px"}if(d-a._captionator_availableCueArea.top-a._captionator_availableCueArea.top>=a._captionator_availableCueArea.bottom-(d+h)&&a._captionator_availableCueArea.bottom>d)a._captionator_availableCueArea.bottom=d;else if(a._captionator_availableCueArea.top0)d=g[0];else throw null;}catch(h){d=document.body,f.appendCueCanvasTo=!1}else d=document.body,f.appendCueCanvasTo=!1;d.appendChild(a)}else document.body.appendChild(a);b._containerObject=a;a.setAttribute("aria-live","polite");a.setAttribute("aria-atomic","true")}String(b.getAttribute("aria-describedby")).indexOf(e)===-1&&(d=b.hasAttribute("aria-describedby")?b.getAttribute("aria-describedby")+" ":"",b.setAttribute("aria-describedby",d+e));d=c.getNodeMetrics(b);b=d.height*(A/100)/96*72; +b=b>=x?b:x;e=Math.floor(b*B);e=e>y?e:y;c.applyStyles(a,{position:"absolute",overflow:"hidden",zIndex:100,height:d.height-d.controlHeight+"px",width:d.width+"px",top:(f.appendCueCanvasTo?0:d.top)+"px",left:(f.appendCueCanvasTo?0:d.left)+"px",color:"white",fontFamily:"Verdana, Helvetica, Arial, sans-serif",fontSize:b+"pt",lineHeight:e+"pt",boxSizing:"border-box"});if(window.navigator.userAgent.toLowerCase().indexOf("chrome/10")>-1)a.style.backgroundColor="rgba(0,0,0,0.01"+Math.random().toString().replace(".", +"")+")"},parseCaptions:function(b,e){var e=e instanceof Object?e:{},a="",f=[],d="",g=[],h=/^(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\,(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/,i=/^(\d+)?:?(\d{2}):(\d{2})\.(\d+)\,(\d+)?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/,v=/^(\d{2})?:?(\d{2}):(\d{2})[\.\,](\d+)\s+\-\-\>\s+(\d{2})?:?(\d{2}):(\d{2})[\.\,](\d+)\s*(.*)/,s=/(\d{2})?:?(\d{2}):(\d{2})[\.\,](\d+)/,m=/^([\d\.]+)\s+\+([\d\.]+)\s*(.*)/,j=/^\[(\d{2})?:?(\d{2})\:(\d{2})\.(\d{2})\]\s*(.*?)$/i,n=/^(DEFAULTS|DEFAULT)\s+\-\-\>\s+(.*)/g, +p=/^(STYLE|STYLES)\s+\-\-\>\s*\n([\s\S]*)/g,w=/^(COMMENT|COMMENTS)\s+\-\-\>\s+(.*)/g;if(b){var t=function(a){var b=new c.CaptionatorCueStructure(a,e),d=[],f,g,h,i=[];h=0;var j=function(a){return!!a.replace(/[^a-z0-9]+/ig,"").length},d=a.split(/(<\/?[^>]+>)/ig).filter(function(a){return!!a.replace(/\s*/ig,"")});h=b;for(f in d)if(d.hasOwnProperty(f))if(g=d[f],g.substr(0,1)==="<")if(g.substr(1,1)==="/"){if(a=g.substr(2).split(/[\s>]+/g)[0],i.length>0){g=0;for(h=i.length-1;h>=0;h--){var m=i[h][i[h].length- +1];g=h;if(m.token===a)break}h=i[g];i=i.slice(0,g)}}else{if(g.substr(1).match(s)||g.match(/^]+>/i)||g.match(/^/)||g.match(/^<(b|i|u|ruby|rt)>/)||e.sanitiseCueHTML!==!1){a={token:g.replace(/[<\/>]+/ig,"").split(/[\s\.]+/)[0],rawToken:g,children:[]};if(a.token==="v")a.voice=g.match(/^]+)>/i)[1];else if(a.token==="c")a.classes=g.replace(/[<\/>\s]+/ig,"").split(/[\.]+/ig).slice(1).filter(j);else if(g=a.rawToken.match(s))b.isTimeDependent=!0,g=g.slice(1),a.timeIn=parseInt((g[0]|| +0)*3600,10)+parseInt((g[1]||0)*60,10)+parseInt(g[2]||0,10)+parseFloat("0."+(g[3]||0));h.push(a);i.push(h);h=a.children}}else e.sanitiseCueHTML!==!1&&(g=g.replace(//g,">").replace(/\&/g,"&"),e.ignoreWhitespace||(g=g.replace(/\n+/g,"
"))),h.push(g);return b},f=b.replace(/\r\n/g,"\n").replace(/\r/g,"\n");j.exec(b)?(f=f.split(/\n+/g),a="LRC"):f=f.split(/\n\n+/g);return f=f.filter(function(b){return b.match(/^WEBVTT(\s*FILE)?/ig)?(a="WebVTT",!1):b.replace(/\s*/ig,"").length? +!0:!1}).map(function(b,f){var k,j,u,l,q="",o;if(o=n.exec(b))return g=o.slice(2).join(""),g=g.split(/\s+/g).filter(function(a){return a&&!!a.length}),null;else if(o=p.exec(b))return d+=o[o.length-1],null;else if(o=w.exec(b))return null;for(k=a==="LRC"?[b.substr(0,b.indexOf("]")),b.substr(b.indexOf("]")+1)]:b.split(/\n/g);!k[0].replace(/\s+/ig,"").length&&k.length>0;)k.shift();for(o=k[0].match(/^\s*[a-z0-9]+\s*$/ig)?String(k.shift().replace(/\s*/ig,"")):f;0