jQuery.webshims.register("track",function(g,d,o,p){var i=d.mediaelement;(new Date).getTime();var r={subtitles:1,captions:1},m=function(a){var b={};a.addEventListener=function(a,h){b[a]&&d.error("always use $.bind to the shimed event: "+a+" already bound fn was: "+b[a]+" your fn was: "+h);b[a]=h};a.removeEventListener=function(a,h){b[a]&&b[a]!=h&&d.error("always use $.bind/$.unbind to the shimed event: "+a+" already bound fn was: "+b[a]+" your fn was: "+h);b[a]&&delete b[a]};return a},s={getCueById:function(a){for(var b= null,e=0,h=this.length;ea.startTime&&d.error("cue startTime higher than previous cue's startTime")}else this.cues=i.createCueList();a.track&&d.error("cue already part of a track element"); a.track=this;this.cues.push(a)},removeCue:function(){d.error("not implemented yet")},DISABLED:"disabled",OFF:"disabled",HIDDEN:"hidden",SHOWING:"showing",ERROR:3,LOADED:2,LOADING:1,NONE:0},u=["kind","label","srclang"],v=Function.prototype.call.bind(Object.prototype.hasOwnProperty),j=function(a,b){var e=[],h=[],c=[],f,k;a||(a=d.data(this,"mediaelementBase")||d.data(this,"mediaelementBase",{}));if(!b)a.blockTrackListUpdate=!0,b=g.prop(this,"textTracks"),a.blockTrackListUpdate=!1;clearTimeout(a.updateTrackListTimer); g("track",this).each(function(){var a=g.prop(this,"track");c.push(a);-1==b.indexOf(a)&&h.push(a)});if(a.scriptedTextTracks)for(f=0,k=a.scriptedTextTracks.length;f")[0];o.TextTrackCue=function(a,b,e){3!=arguments.length&&d.error("wrong arguments.length for TextTrackCue.constructor");this.startTime=a;this.endTime=b;this.text=e;this.id="";this.pauseOnExit=!1;m(this)};o.TextTrackCue.prototype={onenter:null,onexit:null,pauseOnExit:!1,getCueAsHTML:function(){var a="",b="",e=p.createDocumentFragment(),h;if(!v(this,"getCueAsHTML"))h=this.getCueAsHTML=function(){var c,f;if(a!=this.text){a=this.text;b=i.parseCueTextToHTML(a);n.innerHTML=b;for(c= 0,f=n.childNodes.length;c]+>)/ig,b=/^(?:c|v|ruby|rt|b|i|u)/,e=/\<\s*\//,h=function(a,b,c,h){e.test(h)?a="":(c.splice(0,1),a="<"+a+" "+b+'="'+c.join(" ").replace(/\"/g,""")+'">');return a},c=function(a){var c=a.replace(/[<\/>]+/ig,"").split(/[\s\.]+/); c[0]&&(c[0]=c[0].toLowerCase(),b.test(c[0])?"c"==c[0]?a=h("span","class",c,a):"v"==c[0]&&(a=h("q","title",c,a)):a="");return a};return function(b){return b.replace(a,c)}}();i.loadTextTrack=function(a,b,e,h){var c=e.track,f=function(){var h=g.prop(b,"src"),e,l;if("disabled"!=c.mode&&h&&g.attr(b,"src")&&(g(a).unbind("play playing timeupdate updatetrackdisplay",f),g(b).unbind("checktrackmode",f),!c.readyState)){e=function(){c.readyState=3;c.cues=null;c.activeCues=c.shimActiveCues=c._shimActiveCues=null; g(b).triggerHandler("error")};c.readyState=1;try{c.cues=i.createCueList(),c.activeCues=c.shimActiveCues=c._shimActiveCues=i.createCueList(),l=g.ajax({dataType:"text",url:h,success:function(f){"text/vtt"!=l.getResponseHeader("content-type")&&d.error("set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt");i.parseCaptions(f,c,function(f){f&&"length"in f?(c.readyState=2,g(b).triggerHandler("load"),g(a).triggerHandler("updatetrackdisplay")):e()})},error:e})}catch(j){e(), d.warn(j)}}};c.readyState=0;c.shimActiveCues=null;c._shimActiveCues=null;c.activeCues=null;c.cues=null;g(a).unbind("play playing timeupdate updatetrackdisplay",f);g(b).unbind("checktrackmode",f);g(a).bind("play playing timeupdate updatetrackdisplay",f);g(b).bind("checktrackmode",f);if(h)c.mode=r[c.kind]?"showing":"hidden",f()};i.createTextTrack=function(a,b){var e,h;if(b.nodeName&&(h=d.data(b,"trackData")))q(b,h),e=h.track;if(!e)e=m(d.objectCreate(t)),u.forEach(function(a){var f=g.prop(b,a);f&&("srclang"== a&&(a="language"),e[a]=f)}),b.nodeName?(h=d.data(b,"trackData",{track:e}),i.loadTextTrack(a,b,h,g.prop(b,"default"))):(e.cues=i.createCueList(),e.activeCues=e._shimActiveCues=e.shimActiveCues=i.createCueList(),e.mode="hidden",e.readyState=2);return e};i.parseCaptionChunk=function(){var a=/^(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s+\-\-\>\s+(\d{2})?:?(\d{2}):(\d{2})\.(\d+)\s*(.*)/,b=/^(DEFAULTS|DEFAULT)\s+\-\-\>\s+(.*)/g,e=/^(STYLE|STYLES)\s+\-\-\>\s*\n([\s\S]*)/g,h=/^(COMMENT|COMMENTS)\s+\-\-\>\s+(.*)/g; return function(c){var f,d,g,i;if(b.exec(c)||e.exec(c)||h.exec(c))return null;for(c=c.split(/\n/g);!c[0].replace(/\s+/ig,"").length&&0=m&& (j||d.error("please use WebVTT format. This is the standard"),e(b.cues))},a=a.replace(/\r\n/g,"\n"),setTimeout(function(){a=a.replace(/\r/g,"\n");setTimeout(function(){g=(new Date).getTime();a=a.split(/\n\n+/g);c(0,a.length)},9)},9)):d.error("Required parameter captionData not supplied.")};i.createTrackList=function(a,b){b=b||d.data(a,"mediaelementBase")||d.data(a,"mediaelementBase",{});if(!b.textTracks)b.textTracks=[],d.defineProperties(b.textTracks,{onaddtrack:{value:null},onremovetrack:{value:null}}), m(b.textTracks);return b.textTracks};Modernizr.track||(d.defineNodeNamesBooleanProperty(["track"],"default"),d.reflectProperties(["track"],["srclang","label"]),d.defineNodeNameProperties("track",{src:{reflect:!0,propType:"src"}}));d.defineNodeNameProperties("track",{kind:{attr:Modernizr.track?{set:function(a){var b=d.data(this,"trackData");this.setAttribute("data-kind",a);if(b)b.attrKind=a},get:function(){var a=d.data(this,"trackData");return a&&"attrKind"in a?a.attrKind:this.getAttribute("kind")}}: {},reflect:!0,propType:"enumarated",defaultValue:"subtitles",limitedTo:["subtitles","captions","descriptions","chapters","metadata"]}});d.onNodeNamesPropertyModify("track","kind",function(){var a=d.data(this,"trackData");if(a)a.track.kind=g.prop(this,"kind"),q(this,a)});d.onNodeNamesPropertyModify("track","src",function(a){if(a){var a=d.data(this,"trackData"),b;a&&(b=g(this).closest("video, audio"),b[0]&&i.loadTextTrack(b,this,a))}});d.defineNodeNamesProperties(["track"],{ERROR:{value:3},LOADED:{value:2}, LOADING:{value:1},NONE:{value:0},readyState:{get:function(){return(g.prop(this,"track")||{readyState:0}).readyState},writeable:!1},track:{get:function(){return i.createTextTrack(g(this).closest("audio, video")[0],this)},writeable:!1}},"prop");d.defineNodeNamesProperties(["audio","video"],{textTracks:{get:function(){var a=d.data(this,"mediaelementBase")||d.data(this,"mediaelementBase",{}),b=i.createTrackList(this,a);a.blockTrackListUpdate||j.call(this,a,b);return b},writeable:!1},addTextTrack:{value:function(a, b,e){a=i.createTextTrack(this,{kind:a||"",label:b||"",srclang:e||""});b=d.data(this,"mediaelementBase")||d.data(this,"mediaelementBase",{});if(!b.scriptedTextTracks)b.scriptedTextTracks=[];b.scriptedTextTracks.push(a);j.call(this);return a}}},"prop");g(p).bind("emptied ended updatetracklist",function(a){if(g(a.target).is("audio, video")){var b=d.data(a.target,"mediaelementBase");if(b)clearTimeout(b.updateTrackListTimer),b.updateTrackListTimer=setTimeout(function(){j.call(a.target,b)},0)}});d.addReady(function(a, b){var e=b.filter("video, audio, track").closest("audio, video");g("video, audio",a).add(e).each(function(){j.call(this)}).each(function(){if(Modernizr.track){var a=this.textTracks;g.prop(this,"textTracks").length!=a.length&&d.error("textTracks couldn't be copied");g("track",this).each(function(){var a=g.prop(this,"track"),b=this.track,d,e;if(b){d=g.prop(this,"kind");e=b.readyState||this.readyState;if(b.mode||e)a.mode=b.mode;if("descriptions"!=d)b.mode="string"==typeof b.mode?"disabled":0,this.kind= "metadata",g(this).attr({kind:d})}}).bind("load error",function(a){a.originalEvent&&a.stopImmediatePropagation()})}});e.each(function(){var a=this,b=d.data(a,"mediaelementBase");if(b)clearTimeout(b.updateTrackListTimer),b.updateTrackListTimer=setTimeout(function(){j.call(a,b)},9)})});Modernizr.track&&g("video, audio").trigger("trackapichange")});