1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
|
!function(a){if(webshims.support.texttrackapi&&document.addEventListener){var b=webshims.cfg.track,c=function(b){a(b.target).filter("track").each(e)},d=webshims.bugs.track,e=function(){return d||!b.override&&3==a.prop(this,"readyState")?(b.override=!0,webshims.reTest("track"),document.removeEventListener("error",c,!0),this&&a.nodeName(this,"track")?webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type"):webshims.info("track support was overwritten. due to bad browser support"),!1):void 0},f=function(){document.addEventListener("error",c,!0),d?e():a("track").each(e),d||b.override||webshims.defineProperty(TextTrack.prototype,"shimActiveCues",{get:function(){return this._shimActiveCues||this.activeCues}})};b.override||a(f)}}(webshims.$),webshims.register("track-ui",function(a,b,c,d,e){"use strict";function f(a,b){var c=!0,d=0,e=a.length;if(e!=b.length)c=!1;else for(;e>d;d++)if(a[d]!=b[d]){c=!1;break}return c}function g(c,d,e,f,g){var h,i,j=a.Event("cuechange");e.trackElements||(e.trackElements=f[0].getElementsByTagName("track")),h=e.trackElements[g],h&&(i=(b.data(h,"trackData")||{track:a.prop(h,"track")}).track,i!=c.track&&(h=null)),a.event.trigger(j,null,c.track,!0),h&&a.event.trigger(j,null,h,!0),a.event.trigger(d,null,c,!0)}var h=b.cfg.track,i=b.support,j={subtitles:1,captions:1,descriptions:1},k=b.mediaelement,l=function(){return!h.override&&i.texttrackapi},m=c.cancelAnimationFrame&&c.requestAnimationFrame||function(a){setTimeout(a,17)},n=c.cancelAnimationFrame||c.clearTimeout,o={update:function(c,d){c.activeCues.length?f(c.displayedActiveCues,c.activeCues)||(c.displayedActiveCues=c.activeCues,c.trackDisplay||(c.trackDisplay=a('<div class="cue-display '+b.shadowClass+'"><span class="description-cues" aria-live="assertive" /></div>').insertAfter(d),this.addEvents(c,d),b.docObserve()),c.hasDirtyTrackDisplay&&d.triggerHandler("forceupdatetrackdisplay"),this.showCues(c)):this.hide(c)},showCues:function(b){var c=a('<span class="cue-wrapper" />');a.each(b.displayedActiveCues,function(d,e){var f=e.id?'id="cue-id-'+e.id+'"':"",g=a('<span class="cue-line"><span '+f+' class="cue" /></span>').find("span").html(e.getCueAsHTML()).end();"descriptions"==e.track.kind?setTimeout(function(){a("span.description-cues",b.trackDisplay).html(g)},0):c.prepend(g)}),a("span.cue-wrapper",b.trackDisplay).remove(),b.trackDisplay.append(c)},addEvents:function(a,b){if(h.positionDisplay){var c,d=function(c){if(a.displayedActiveCues.length||c===!0){a.trackDisplay.css({display:"none"});var d=b.getShadowElement(),e=d.innerHeight(),f=d.innerWidth(),g=d.position();a.trackDisplay.css({left:g.left,width:f,height:e-45,top:g.top,display:"block"}),a.trackDisplay.css("fontSize",Math.max(Math.round(e/30),7)),a.hasDirtyTrackDisplay=!1}else a.hasDirtyTrackDisplay=!0},e=function(){clearTimeout(c),c=setTimeout(d,0)},f=function(){d(!0)};b.on("playerdimensionchange mediaelementapichange updatetrackdisplay updatemediaelementdimensions swfstageresize",e),b.on("forceupdatetrackdisplay",f).onWSOff("updateshadowdom",e),f()}},hide:function(b){b.trackDisplay&&b.displayedActiveCues.length&&(b.displayedActiveCues=[],a("span.cue-wrapper",b.trackDisplay).remove(),a("span.description-cues",b.trackDisplay).empty())}};if(k.trackDisplay=o,!k.createCueList){var p={getCueById:function(a){for(var b=null,c=0,d=this.length;d>c;c++)if(this[c].id===a){b=this[c];break}return b}};k.createCueList=function(){return a.extend([],p)}}k.getActiveCue=function(b,c,d,e,f){b._lastFoundCue||(b._lastFoundCue={index:0,time:0}),b._shimActiveCues||!i.texttrackapi||h.override||(b._shimActiveCues=k.createCueList());for(var l,m,n,o=0;o<b.shimActiveCues.length;o++)m=b.shimActiveCues[o],m.startTime>d||m.endTime<d?(b.shimActiveCues.splice(o,1),o--,m.pauseOnExit&&a(c).pause(),g(m,"exit",e,c,f)):(n=m.endTime-d,e.nextUpdateDelay>n&&(e.nextUpdateDelay=n,e.nextEvent=m.endTime),"showing"==b.mode&&j[b.kind]&&-1==a.inArray(m,e.activeCues)&&e.activeCues.push(m));for(l=b.cues.length,o=b._lastFoundCue.time<d?b._lastFoundCue.index:0;l>o;o++)if(m=b.cues[o],m.startTime<=d&&m.endTime
|