Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- 1.1.6 release notes (chapters)

  • Loading branch information...
commit bce38c319e80194b7622a3df8f772a3fdcb9eda4 1 parent 528eeba
@johndyer johndyer authored
View
69 build/mediaelement-and-player.js
@@ -1098,6 +1098,9 @@ window.MediaElement = mejs.MediaElement;
}, true);
t.mediaElement.addEventListener('loadedmetadata', function(e) {
+
+ t.displayChapters();
+
// if the <video height> was not set and the options.videoHeight was not set
// then resize to the real dimensions
if (t.isVideo && t.options.videoHeight <= 0 && t.$media[0].getAttribute('height') === null && !isNaN(e.target.videoHeight)) {
@@ -1124,6 +1127,7 @@ window.MediaElement = mejs.MediaElement;
i;
t.captionsDisplay = t.container.find('.mep-captions-layer').hide();
t.captionsText = t.container.find('.mep-captions-text');
+ t.chapters = t.container.find('.mep-chapters');
if (t.options.translationSelector) {
for (i in mejs.language.codes) {
@@ -1247,7 +1251,7 @@ window.MediaElement = mejs.MediaElement;
t.loadTrack(t.trackToLoad);
} else {
// add done?
- t.isLoadingTrack = false;
+ t.isLoadingTrack = false;
}
},
@@ -1286,6 +1290,10 @@ window.MediaElement = mejs.MediaElement;
// parse the loaded file
track.entries = mejs.SrtParser.parse(d);
after();
+
+ if (track.kind == 'chapters' && t.mediaElement.duration > 0) {
+ t.buildChapters(track);
+ }
},
error: function() {
t.loadNextTrack();
@@ -1361,6 +1369,56 @@ window.MediaElement = mejs.MediaElement;
}
},
+ displayChapters: function() {
+ var
+ t = this,
+ i;
+
+ for (i=0; i<t.tracks.length; i++) {
+ if (t.tracks[i].kind == 'chapters') {
+ t.buildChapters(t.tracks[i]);
+ break;
+ }
+ }
+ },
+
+ buildChapters: function(chapters) {
+ var
+ t = this,
+ i,
+ dur,
+ width,
+ left
+ ;
+
+ t.chapters.empty();
+
+ for (i=0; i<chapters.entries.times.length; i++) {
+ dur = chapters.entries.times[i].stop - chapters.entries.times[i].start;
+ //width = length / t.mediaElement.duration * 100;
+ width = Math.floor(t.width * dur / t.mediaElement.duration);
+ left = Math.floor(t.width * chapters.entries.times[i].start / t.mediaElement.duration);
+ if (left + width > t.width) {
+ width = t.width - left;
+ }
+
+ t.chapters.append( $(
+ '<div class="mep-chapter" rel="' + chapters.entries.times[i].start + '" style="left: ' + left.toString() + 'px;width: ' + width.toString() + 'px;">' +
+ '<div class="mep-chapter-block' + ((i==chapters.entries.times.length-1) ? ' mep-chapter-block-last' : '') + '">' +
+ '<span class="ch-title">' + chapters.entries.text[i] + '</span>' +
+ '<span class="ch-time">' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].start) + '&ndash;' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].stop) + '</span>' +
+ '</div>' +
+ '</div>'));
+ }
+
+ t.chapters.find('div.mep-chapter').click(function() {
+ t.mediaElement.setCurrentTime( parseFloat( $(this).attr('rel') ) );
+ if (t.mediaElement.paused) {
+ t.mediaElement.play();
+ }
+ });
+ },
+
buildPoster: function() {
var t = this;
@@ -1464,6 +1522,10 @@ window.MediaElement = mejs.MediaElement;
t.captionsDisplay.css('padding-bottom', t.controls.height() + 5);
t.setRailSize();
t.isControlsVisible = true;
+
+ // chapters
+ t.chapters.css('visibility','visible');
+ t.chapters.fadeIn(200);
})
.bind('mouseleave', function () {
if (!t.mediaElement.paused) {
@@ -1473,6 +1535,11 @@ window.MediaElement = mejs.MediaElement;
t.captionsDisplay.css('padding-bottom', 10);
});
t.isControlsVisible = false;
+
+ t.chapters.fadeOut(200, function() {
+ $(this).css('visibility','hidden');
+ $(this).css('display','block');
+ });
}
});
}
View
2  build/mediaelement-and-player.min.js
@@ -24,4 +24,4 @@ var mejs=mejs||{};mejs.version="1.1.5";mejs.meIndex=0;mejs.plugins={silverlight:
*
* Version: 1.1.3
*/
-(function(a){mejs.MepDefaults={defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,audioWidth:300,audioHeight:30,startVolume:0.8,loop:false,startLanguage:"",translations:[],translationSelector:false,googleApiKey:"",controls:{playpause:true,timerail:true,duration:true,volume:true,captions:true,fullscreen:true},controlsTemplate:'<div class="mep-playpause-button mep-play"><span></span></div><div class="mep-time-rail"><span class="mep-time-total"><span class="mep-time-loaded"></span><span class="mep-time-current"></span><span class="mep-time-handle"></span></span></div><div class="mep-time"><span class="mep-currenttime"></span><span>&nbsp;|&nbsp;</span><span class="mep-duration"></span></div><div class="mep-captions-button"><span></span><div class="mep-captions-selector"><ul></ul></div></div><div class="mep-volume-button mep-mute"><span></span><div class="mep-volume-slider"><div class="mep-volume-rail"><div class="mep-volume-handle"></div></div></div></div><div class="mep-fullscreen-button"><span></span></div>'};mejs.mepIndex=0;mejs.MediaElementPlayer=function(d,e){var b=this,c=mejs.MediaFeatures;b.$media=a(d);b.options=a.extend(true,{},mejs.MepDefaults,e);b.isVideo=(b.$media[0].tagName.toLowerCase()=="video");if(c.isiPad||c.isiPhone){b.$media.attr("controls","controls");b.$media.removeAttr("poster");if(c.isiPad&&b.$media[0].getAttribute("autoplay")!==null){b.$media[0].load();b.$media[0].play()}return}else{if(c.isAndroid&&b.isVideo){b.$media.attr("controls","controls");return}else{b.$media.removeAttr("controls")}}b.createPlayer()};mejs.MediaElementPlayer.prototype={createPlayer:function(){var b=this,c=a.extend(true,{},b.options,{success:function(d,e){b.setupPlayer(d,e)},error:function(d){b.handleError(d)}});b.id="mep_"+mejs.mepIndex++;b.$media.before(a('<div id="'+b.id+'" class="mep-container"><div class="mep-mediaelement"></div><div class="mep-captions-layer"><span class="mep-captions-text"></span></div><div class="mep-poster"><img /></div><div class="mep-overlay"><div class="mep-overlay-button"></div></div><div class="mep-chapters"></div><div class="mep-controls">'+b.options.controlsTemplate+'</div><div class="mep-clear"></div></div>'));b.container=a("#"+this.id);b.container.find(".mep-captions-selector ul").append(a('<li><input type="radio" name="'+this.id+'_captions" id="'+this.id+'_captions_none" value="none" checked="checked" /><label for="'+this.id+'_captions_none">None</label></li>'));b.container.addClass(b.$media[0].className).find(".mep-mediaelement").append(b.$media);if(b.isVideo){b.width=(b.options.videoWidth>0)?b.options.videoWidth:(b.$media[0].getAttribute("width")!==null)?b.$media.attr("width"):b.options.defaultVideoWidth;b.height=(b.options.videoHeight>0)?b.options.videoHeight:(b.$media[0].getAttribute("height")!==null)?b.$media.attr("height"):b.options.defaultVideoHeight}else{b.width=b.options.audioWidth;b.height=b.options.audioHeight}b.buildPoster();b.buildOverlay();b.buildCaptionsDisplay();b.setPlayerSize(b.width,b.height);b.buildControls();c.pluginWidth=b.height;c.pluginHeight=b.width;mejs.MediaElement(b.$media[0],c)},setupPlayer:function(b,d){var c=this;c.mediaElement=b;c.domNode=d;if(c.isVideo){c.overlay.show()}c.buildControlBar();c.buildPlayPause();c.buildTimeRail();c.buildVolumeControls();c.buildCaptionsControls();c.buildFullscreen();c.mediaElement.addEventListener("click",function(f){if(c.mediaElement.paused){c.mediaElement.play()}},true);c.mediaElement.addEventListener("play",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("playing",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("pause",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("paused",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("ended",function(f){c.mediaElement.setCurrentTime(0);c.mediaElement.pause();if(c.options.loop){c.mediaElement.play()}else{c.poster.show();c.overlay.show();c.controls.css("visibility","visible");c.playpause.removeClass("mep-pause").addClass("mep-play");c.setTimePosition()}},true);c.mediaElement.addEventListener("loadedmetadata",function(f){if(c.isVideo&&c.options.videoHeight<=0&&c.$media[0].getAttribute("height")===null&&!isNaN(f.target.videoHeight)){c.setPlayerSize(f.target.videoWidth,f.target.videoHeight);c.setRailSize();c.mediaElement.setVideoSize(f.target.videoWidth,f.target.videoHeight)}},true);setTimeout(function(){c.setRailSize()},50);if(c.options.success){c.options.success(c.mediaElement,c.domNode)}this.findTracks()},buildCaptionsDisplay:function(){var d=this,b="",c;d.captionsDisplay=d.container.find(".mep-captions-layer").hide();d.captionsText=d.container.find(".mep-captions-text");if(d.options.translationSelector){for(c in mejs.language.codes){b+='<option value="'+c+'">'+mejs.language.codes[c]+"</option>"}d.container.find(".mep-captions-selector ul").before(a('<select class="mep-captions-translations"><option value="">--Add Translation--</option>'+b+"</select>"));d.container.find(".mep-captions-translations").change(function(){var e=a(this);lang=e.val();if(lang!=""){d.tracks.push({srclang:lang,src:null,entries:[],isLoaded:false,isTranslation:true});if(!d.isLoadingTrack){d.trackToLoad--;d.addTrackButton(lang,true);d.options.startLanguage=lang;d.loadNextTrack()}}})}},buildCaptionsControls:function(){var c=this,d,b;c.captions.delegate("input[type=radio]","click",function(){d=this.value;if(d=="none"){c.selectedTrack=null}else{for(b=0;b<c.tracks.length;b++){if(c.tracks[b].srclang==d){c.selectedTrack=c.tracks[b];c.captionsDisplay.attr("lang",c.selectedTrack.srclang);c.displayCaptions();break}}}})},findTracks:function(){var c=this,b,d=c.$media.find("track");c.tracks=[];c.trackToLoad=-1;c.selectedTrack=null;c.isLoadingTrack=false;d.each(function(){c.tracks.push({srclang:a(this).attr("srclang").toLowerCase(),src:a(this).attr("src"),kind:a(this).attr("kind"),entries:[],isLoaded:false,isTranslation:false})});if(c.tracks.length>0&&c.options.translations.length>0){for(b=0;b<c.options.translations.length;b++){c.tracks.push({srclang:c.options.translations[b].toLowerCase(),src:null,kind:"subtitles",entries:[],isLoaded:false,isTranslation:true})}}for(b=0;b<c.tracks.length;b++){if(c.tracks[b].kind=="subtitles"){c.addTrackButton(c.tracks[b].srclang,c.tracks[b].isTranslation)}}if(c.tracks.length>0){c.loadNextTrack()}else{c.captions.remove();c.setRailSize()}},loadNextTrack:function(){var b=this;b.trackToLoad++;if(b.trackToLoad<b.tracks.length){b.isLoadingTrack=true;b.loadTrack(b.trackToLoad)}else{b.isLoadingTrack=false}},loadTrack:function(c){var d=this,b=d.tracks[c],e=function(){b.isLoaded=true;d.enableTrackButton(b.srclang);d.loadNextTrack()};if(b.isTranslation){mejs.SrtParser.translateSrt(d.tracks[0].entries,d.tracks[0].srclang,b.srclang,d.options.googleApiKey,function(f){b.entries=f;e()})}else{a.ajax({url:b.src,success:function(f){b.entries=mejs.SrtParser.parse(f);e()},error:function(){d.loadNextTrack()}})}},enableTrackButton:function(c){var b=this;b.captions.find("input[value="+c+"]").attr("disabled","").siblings("label").html(mejs.language.codes[c]||c);if(b.options.startLanguage==c){a("#"+b.id+"_captions_"+c).click()}b.adjustLanguageBox()},addTrackButton:function(e,d){var c=this,b=mejs.language.codes[e]||e;c.captions.find("ul").append(a('<li><input type="radio" name="'+c.id+'_captions" id="'+c.id+"_captions_"+e+'" value="'+e+'" disabled="disabled" /><label for="'+c.id+"_captions_"+e+'">'+b+((d)?" (translating)":" (loading)")+"</label></li>"));c.adjustLanguageBox();c.container.find(".mep-captions-translations option[value="+e+"]").remove()},adjustLanguageBox:function(){var b=this;b.captions.find(".mep-captions-selector").height(b.captions.find(".mep-captions-selector ul").outerHeight(true)+b.captions.find(".mep-captions-translations").outerHeight(true))},displayCaptions:function(){if(typeof this.tracks=="undefined"){return}var d=this,c,b=d.selectedTrack;if(b!=null&&b.isLoaded){for(c=0;c<b.entries.times.length;c++){if(d.mediaElement.currentTime>=b.entries.times[c].start&&d.mediaElement.currentTime<=b.entries.times[c].stop){d.captionsText.html(b.entries.text[c]);d.captionsDisplay.show();return}}d.captionsDisplay.hide()}else{d.captionsDisplay.hide()}},buildPoster:function(){var b=this;b.poster=b.container.find(".mep-poster");b.posterImg=b.poster.find("img");b.posterUrl=b.$media.attr("poster");b.posterUrl=(b.posterUrl===null||b.posterUrl==undefined)?"":b.posterUrl;if(b.posterUrl!==""){b.posterImg.attr("src",b.posterUrl)}else{b.poster.hide()}},buildOverlay:function(){var b=this;b.overlay=b.container.find(".mep-overlay");b.overlay.bind("click",function(c){if(b.mediaElement.paused){b.mediaElement.play()}});b.overlay.hide()},buildControls:function(){var b=this;b.controls=b.container.find(".mep-controls");b.isControlsVisible=true;b.playpause=b.controls.find(".mep-playpause-button");b.fullscreen=b.controls.find(".mep-fullscreen-button");if(!b.isVideo){b.fullscreen.remove()}b.time=b.controls.find(".mep-time");b.currentTime=b.controls.find(".mep-currenttime").html("00:00");b.duration=b.controls.find(".mep-duration").html("00:00");b.captions=b.controls.find(".mep-captions-button");b.mute=b.controls.find(".mep-volume-button");b.volumeSlider=b.controls.find(".mep-volume-slider");b.volumeRail=b.controls.find(".mep-volume-rail");b.volumeHandle=b.controls.find(".mep-volume-handle");b.timeRail=b.controls.find(".mep-time-rail");b.timeCurrent=b.timeRail.find(".mep-time-current").width(0);b.timeLoaded=b.timeRail.find(".mep-time-loaded").width(0);b.timeTotal=b.timeRail.find(".mep-time-total");b.timeHandle=b.controls.find(".mep-time-handle");b.controls.show();b.setRailSize();b.controls.hide();if(!b.options.controls.playpause){b.playpause.remove()}if(!b.options.controls.timerail){b.timeRail.remove()}if(!b.options.controls.duration){b.time.remove()}if(!b.options.controls.volume){b.mute.remove()}if(!b.options.controls.fullscreen){b.fullscreen.remove()}},buildControlBar:function(){var b=this;b.controls.show();if(b.isVideo){b.container.bind("mouseenter",function(){b.controls.css("visibility","visible");b.controls.fadeIn(200);b.captionsDisplay.css("padding-bottom",b.controls.height()+5);b.setRailSize();b.isControlsVisible=true}).bind("mouseleave",function(){if(!b.mediaElement.paused){b.controls.fadeOut(200,function(){a(this).css("visibility","hidden");a(this).css("display","block");b.captionsDisplay.css("padding-bottom",10)});b.isControlsVisible=false}})}},buildPlayPause:function(){var b=this;b.playpause.bind("click",function(){if(b.playpause.hasClass("mep-play")){b.mediaElement.play();b.playpause.removeClass("mep-play").addClass("mep-pause")}else{b.mediaElement.pause();b.playpause.removeClass("mep-pause").addClass("mep-play")}})},buildTimeRail:function(){var b=this;b.timeRail.delegate("span","click",function(h){var c=h.pageX,i=b.timeTotal.offset(),f=b.timeTotal.outerWidth(),d=((c-i.left)/f),g=d*b.mediaElement.duration;b.mediaElement.setCurrentTime(g)});b.mediaElement.addEventListener("timeupdate",function(c){b.displayCaptions();b.setTimePosition();b.setTimeLoaded(c.target)},true);b.mediaElement.addEventListener("progress",function(c){b.setTimeLoaded(c.target)},true)},setTimePosition:function(){var b=this,d,c;if(b.mediaElement.currentTime&&b.mediaElement.duration){b.currentTime.html(mejs.Utility.secondsToTimeCode(b.mediaElement.currentTime));if(b.mediaElement.duration){b.duration.html(mejs.Utility.secondsToTimeCode(b.mediaElement.duration))}d=b.timeTotal.width()*b.mediaElement.currentTime/b.mediaElement.duration;c=d-(b.timeHandle.width()/2);b.timeCurrent.width(d);b.timeHandle.css("left",c)}},setTimeLoaded:function(d){var b=this,c=null;if(d&&d.bytesTotal!=undefined&&d.bytesTotal>0&&d.bufferedBytes!=undefined){c=d.bufferedBytes/d.bytesTotal}else{if(d&&d.buffered&&d.buffered.length>0&&d.buffered.end&&d.duration){c=d.buffered.end(0)/d.duration}}if(c!==null){b.timeLoaded.width(b.timeTotal.width()*c)}},setRailSize:function(){var b=this,c=b.playpause.outerWidth(true)+b.time.outerWidth(true)+b.mute.outerWidth(true)+b.captions.outerWidth(true)+((b.isVideo)?b.fullscreen.outerWidth(true):0),d=b.controls.width()-c-(b.timeRail.outerWidth(true)-b.timeRail.outerWidth(false));b.timeRail.width(d);b.timeTotal.width(d-(b.timeTotal.outerWidth(true)-b.timeTotal.width()))},setPlayerSize:function(d,b){var c=this;c.width=parseInt(d,10);c.height=parseInt(b,10);c.container.width(c.width).height(c.height);c.captionsDisplay.width(c.width);c.overlay.width(c.width).height(c.height);c.posterImg.height(c.height).width(c.width)},handleError:function(c){var b=this;b.$media.hide();b.overlay.hide();b.controls.hide();b.poster.hide()},buildFullscreen:function(){var b=this;b.isFullScreen=false;b.normalHeight=0;b.normalWidth=0;b.fullscreen.bind("click",function(){b.setFullScreen(!b.isFullScreen)})},setFullScreen:function(b){var c=this;switch(c.mediaElement.pluginType){case"flash":c.mediaElement.setFullscreen(b);break;case"silverlight":c.mediaElement.setFullscreen(b);break;case"native":if(mejs.MediaFeatures.hasNativeFullScreen){if(b){c.mediaElement.webkitEnterFullScreen()}else{c.mediaElement.webkitExitFullScreen()}}else{if(b){c.normalHeight=c.$media.height();c.normalWidth=c.$media.width();c.container.addClass("mep-container-fullscreen").width("100%").height("100%").css("z-index",1000);c.$media.width("100%").height("100%");c.captionsDisplay.width("100%");c.overlay.width("100%").height("100%");c.posterImg.width("100%").height("auto");c.fullscreen.removeClass("mep-fullscreen").addClass("mep-unfullscreen");c.setRailSize();c.escB=function(d){c.escListener(d)};c.resB=function(d){c.resizeListener(d)};a(document).bind("keydown",c.escB);a(window).bind("resize",c.resB)}else{c.container.removeClass("mep-container-fullscreen").width(c.normalWidth).height(c.normalHeight).css("z-index",1);c.$media.width(c.normalWidth).height(c.normalHeight);c.posterImg.width(c.normalWidth).height(c.normalHeight);c.captionsDisplay.width(c.normalWidth);c.fullscreen.removeClass("mep-unfullscreen").addClass("mep-fullscreen");c.setRailSize();a(document).unbind("keydown",c.escB);a(window).unbind("resize",c.resB)}}}c.isFullScreen=b},escListener:function(b){if(b.keyCode==27){this.setFullScreen(false)}},resizeListener:function(b){this.setRailSize()},buildVolumeControls:function(){var b=this;b.vmmB=function(c){b.volumeMove(c)};b.vrmB=function(c){b.removeMouseMove(c)};b.volumeSlider.bind("mousedown",function(c){b.volumeMove(c);a(document).bind("mousemove",b.vmmB).bind("mouseup",b.vrmB)});b.mute.find("span").bind("click",function(){if(b.mediaElement.muted){b.mediaElement.setMuted(false);b.mute.removeClass("mep-unmute").addClass("mep-mute");b.positionVolumeHandle(1)}else{b.mediaElement.setMuted(true);b.mute.removeClass("mep-mute").addClass("mep-unmute");b.positionVolumeHandle(0)}});b.mediaElement.addEventListener("volumechange",function(c){b.positionVolumeHandle(c.target.volume)},true);b.mediaElement.setVolume(b.options.startVolume)},volumeMove:function(g){var c=this,b=c.volumeRail.height(),f=g.pageY-c.volumeRail.offset().top,d=(b-f)/b;if(f<0){f=0}else{if(f>b){f=b}}c.volumeHandle.css("top",f-(c.volumeHandle.height()/2));if(d==0){c.mediaElement.setMuted(true);c.mute.removeClass("mep-mute").addClass("mep-unmute")}else{c.mediaElement.setMuted(false);c.mute.removeClass("mep-unmute").addClass("mep-mute")}c.mediaElement.setVolume(d)},positionVolumeHandle:function(c){var b=this;b.volumeHandle.css("top",b.volumeRail.height()-(b.volumeRail.height()*c)-(b.volumeHandle.height()/2))},removeMouseMove:function(){var b=this;a(document).unbind("mousemove",b.vmmB).unbind("mouseup",b.vrmB)}};mejs.language={codes:{af:"Afrikaans",sq:"Albanian",ar:"Arabic",be:"Belarusian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese","zh-cn":"Chinese Simplified","zh-tw":"Chinese Traditional",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",tl:"Filipino",fi:"Finnish",fr:"French",gl:"Galician",de:"German",el:"Greek",ht:"Haitian Creole",iw:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese",ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",mt:"Maltese",no:"Norwegian",fa:"Persian",pl:"Polish",pt:"Portuguese",ro:"Romanian",ru:"Russian",sr:"Serbian",sk:"Slovak",sl:"Slovenian",es:"Spanish",sw:"Swahili",sv:"Swedish",tl:"Tagalog",th:"Thai",tr:"Turkish",uk:"Ukrainian",vi:"Vietnamese",cy:"Welsh",yi:"Yiddish"}};mejs.SrtParser={pattern_identifier:/^[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{3})?)(.*)$/,timecodeToSeconds:function(b){var c=b.split(":");return c[0]*60*60+c[1]*60+parseFloat(c[2].replace(",","."))},split2:function(c,b){return c.split(b)},parse:function(e){var f=0,d=this.split2(e,/\r?\n/),c={text:[],times:[]},b,g;for(;f<d.length;f++){if(this.pattern_identifier.exec(d[f])){f++;b=this.pattern_timecode.exec(d[f]);if(b&&f<d.length){f++;g=d[f];f++;while(d[f]!==""&&f<d.length){g=g+"\n"+d[f];f++}c.text.push(g);c.times.push({start:this.timecodeToSeconds(b[1]),stop:this.timecodeToSeconds(b[3]),settings:b[5]})}}}return c},translateSrt:function(d,j,f,g,h){var b={text:[],times:[]},c,e;this.translateText(d.text.join(" <a></a>"),j,f,g,function(i){c=i.split("<a></a>");for(e=0;e<d.text.length;e++){b.text[e]=c[e];b.times[e]={start:d.times[e].start,stop:d.times[e].stop,settings:d.times[e].settings}}h(b)})},translateText:function(j,f,d,c,i){var l,e=[],h,b=1000,k="",g=function(){if(e.length>0){h=e.shift();mejs.SrtParser.translateChunk(h,f,d,c,function(m){if(m!="undefined"){k+=m}g()})}else{i(k)}};while(j.length>0){if(j.length>b){l=j.lastIndexOf(".",b);e.push(j.substring(0,l));j=j.substring(l+1)}else{e.push(j);j=""}}g()},translateChunk:function(e,g,c,d,f){var b={q:e,langpair:g+"|"+c,v:"1.0"};if(d!==""&&d!==null){b.key=d}a.ajax({url:"https://ajax.googleapis.com/ajax/services/language/translate",data:b,type:"GET",dataType:"jsonp",success:function(h){f(h.responseData.translatedText)},error:function(h){f(null)}})}};if("x\n\ny".split(/\n/gi).length!=3){mejs.SrtParser.split2=function(f,d){var e=[],b="",c;for(c=0;c<f.length;c++){b+=f.substring(c,c+1);if(d.test(b)){e.push(b.replace(d,""));b=""}}e.push(b);return e}}jQuery.fn.mediaelementplayer=function(b){return this.each(function(){return new mejs.MediaElementPlayer(a(this),b)})};window.MediaElementPlayer=mejs.MediaElementPlayer})(jQuery);
+(function(a){mejs.MepDefaults={defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,audioWidth:300,audioHeight:30,startVolume:0.8,loop:false,startLanguage:"",translations:[],translationSelector:false,googleApiKey:"",controls:{playpause:true,timerail:true,duration:true,volume:true,captions:true,fullscreen:true},controlsTemplate:'<div class="mep-playpause-button mep-play"><span></span></div><div class="mep-time-rail"><span class="mep-time-total"><span class="mep-time-loaded"></span><span class="mep-time-current"></span><span class="mep-time-handle"></span></span></div><div class="mep-time"><span class="mep-currenttime"></span><span>&nbsp;|&nbsp;</span><span class="mep-duration"></span></div><div class="mep-captions-button"><span></span><div class="mep-captions-selector"><ul></ul></div></div><div class="mep-volume-button mep-mute"><span></span><div class="mep-volume-slider"><div class="mep-volume-rail"><div class="mep-volume-handle"></div></div></div></div><div class="mep-fullscreen-button"><span></span></div>'};mejs.mepIndex=0;mejs.MediaElementPlayer=function(d,e){var b=this,c=mejs.MediaFeatures;b.$media=a(d);b.options=a.extend(true,{},mejs.MepDefaults,e);b.isVideo=(b.$media[0].tagName.toLowerCase()=="video");if(c.isiPad||c.isiPhone){b.$media.attr("controls","controls");b.$media.removeAttr("poster");if(c.isiPad&&b.$media[0].getAttribute("autoplay")!==null){b.$media[0].load();b.$media[0].play()}return}else{if(c.isAndroid&&b.isVideo){b.$media.attr("controls","controls");return}else{b.$media.removeAttr("controls")}}b.createPlayer()};mejs.MediaElementPlayer.prototype={createPlayer:function(){var b=this,c=a.extend(true,{},b.options,{success:function(d,e){b.setupPlayer(d,e)},error:function(d){b.handleError(d)}});b.id="mep_"+mejs.mepIndex++;b.$media.before(a('<div id="'+b.id+'" class="mep-container"><div class="mep-mediaelement"></div><div class="mep-captions-layer"><span class="mep-captions-text"></span></div><div class="mep-poster"><img /></div><div class="mep-overlay"><div class="mep-overlay-button"></div></div><div class="mep-chapters"></div><div class="mep-controls">'+b.options.controlsTemplate+'</div><div class="mep-clear"></div></div>'));b.container=a("#"+this.id);b.container.find(".mep-captions-selector ul").append(a('<li><input type="radio" name="'+this.id+'_captions" id="'+this.id+'_captions_none" value="none" checked="checked" /><label for="'+this.id+'_captions_none">None</label></li>'));b.container.addClass(b.$media[0].className).find(".mep-mediaelement").append(b.$media);if(b.isVideo){b.width=(b.options.videoWidth>0)?b.options.videoWidth:(b.$media[0].getAttribute("width")!==null)?b.$media.attr("width"):b.options.defaultVideoWidth;b.height=(b.options.videoHeight>0)?b.options.videoHeight:(b.$media[0].getAttribute("height")!==null)?b.$media.attr("height"):b.options.defaultVideoHeight}else{b.width=b.options.audioWidth;b.height=b.options.audioHeight}b.buildPoster();b.buildOverlay();b.buildCaptionsDisplay();b.setPlayerSize(b.width,b.height);b.buildControls();c.pluginWidth=b.height;c.pluginHeight=b.width;mejs.MediaElement(b.$media[0],c)},setupPlayer:function(b,d){var c=this;c.mediaElement=b;c.domNode=d;if(c.isVideo){c.overlay.show()}c.buildControlBar();c.buildPlayPause();c.buildTimeRail();c.buildVolumeControls();c.buildCaptionsControls();c.buildFullscreen();c.mediaElement.addEventListener("click",function(f){if(c.mediaElement.paused){c.mediaElement.play()}},true);c.mediaElement.addEventListener("play",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("playing",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("pause",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("paused",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("ended",function(f){c.mediaElement.setCurrentTime(0);c.mediaElement.pause();if(c.options.loop){c.mediaElement.play()}else{c.poster.show();c.overlay.show();c.controls.css("visibility","visible");c.playpause.removeClass("mep-pause").addClass("mep-play");c.setTimePosition()}},true);c.mediaElement.addEventListener("loadedmetadata",function(f){c.displayChapters();if(c.isVideo&&c.options.videoHeight<=0&&c.$media[0].getAttribute("height")===null&&!isNaN(f.target.videoHeight)){c.setPlayerSize(f.target.videoWidth,f.target.videoHeight);c.setRailSize();c.mediaElement.setVideoSize(f.target.videoWidth,f.target.videoHeight)}},true);setTimeout(function(){c.setRailSize()},50);if(c.options.success){c.options.success(c.mediaElement,c.domNode)}this.findTracks()},buildCaptionsDisplay:function(){var d=this,b="",c;d.captionsDisplay=d.container.find(".mep-captions-layer").hide();d.captionsText=d.container.find(".mep-captions-text");d.chapters=d.container.find(".mep-chapters");if(d.options.translationSelector){for(c in mejs.language.codes){b+='<option value="'+c+'">'+mejs.language.codes[c]+"</option>"}d.container.find(".mep-captions-selector ul").before(a('<select class="mep-captions-translations"><option value="">--Add Translation--</option>'+b+"</select>"));d.container.find(".mep-captions-translations").change(function(){var e=a(this);lang=e.val();if(lang!=""){d.tracks.push({srclang:lang,src:null,entries:[],isLoaded:false,isTranslation:true});if(!d.isLoadingTrack){d.trackToLoad--;d.addTrackButton(lang,true);d.options.startLanguage=lang;d.loadNextTrack()}}})}},buildCaptionsControls:function(){var c=this,d,b;c.captions.delegate("input[type=radio]","click",function(){d=this.value;if(d=="none"){c.selectedTrack=null}else{for(b=0;b<c.tracks.length;b++){if(c.tracks[b].srclang==d){c.selectedTrack=c.tracks[b];c.captionsDisplay.attr("lang",c.selectedTrack.srclang);c.displayCaptions();break}}}})},findTracks:function(){var c=this,b,d=c.$media.find("track");c.tracks=[];c.trackToLoad=-1;c.selectedTrack=null;c.isLoadingTrack=false;d.each(function(){c.tracks.push({srclang:a(this).attr("srclang").toLowerCase(),src:a(this).attr("src"),kind:a(this).attr("kind"),entries:[],isLoaded:false,isTranslation:false})});if(c.tracks.length>0&&c.options.translations.length>0){for(b=0;b<c.options.translations.length;b++){c.tracks.push({srclang:c.options.translations[b].toLowerCase(),src:null,kind:"subtitles",entries:[],isLoaded:false,isTranslation:true})}}for(b=0;b<c.tracks.length;b++){if(c.tracks[b].kind=="subtitles"){c.addTrackButton(c.tracks[b].srclang,c.tracks[b].isTranslation)}}if(c.tracks.length>0){c.loadNextTrack()}else{c.captions.remove();c.setRailSize()}},loadNextTrack:function(){var b=this;b.trackToLoad++;if(b.trackToLoad<b.tracks.length){b.isLoadingTrack=true;b.loadTrack(b.trackToLoad)}else{b.isLoadingTrack=false}},loadTrack:function(c){var d=this,b=d.tracks[c],e=function(){b.isLoaded=true;d.enableTrackButton(b.srclang);d.loadNextTrack()};if(b.isTranslation){mejs.SrtParser.translateSrt(d.tracks[0].entries,d.tracks[0].srclang,b.srclang,d.options.googleApiKey,function(f){b.entries=f;e()})}else{a.ajax({url:b.src,success:function(f){b.entries=mejs.SrtParser.parse(f);e();if(b.kind=="chapters"&&d.mediaElement.duration>0){d.buildChapters(b)}},error:function(){d.loadNextTrack()}})}},enableTrackButton:function(c){var b=this;b.captions.find("input[value="+c+"]").attr("disabled","").siblings("label").html(mejs.language.codes[c]||c);if(b.options.startLanguage==c){a("#"+b.id+"_captions_"+c).click()}b.adjustLanguageBox()},addTrackButton:function(e,d){var c=this,b=mejs.language.codes[e]||e;c.captions.find("ul").append(a('<li><input type="radio" name="'+c.id+'_captions" id="'+c.id+"_captions_"+e+'" value="'+e+'" disabled="disabled" /><label for="'+c.id+"_captions_"+e+'">'+b+((d)?" (translating)":" (loading)")+"</label></li>"));c.adjustLanguageBox();c.container.find(".mep-captions-translations option[value="+e+"]").remove()},adjustLanguageBox:function(){var b=this;b.captions.find(".mep-captions-selector").height(b.captions.find(".mep-captions-selector ul").outerHeight(true)+b.captions.find(".mep-captions-translations").outerHeight(true))},displayCaptions:function(){if(typeof this.tracks=="undefined"){return}var d=this,c,b=d.selectedTrack;if(b!=null&&b.isLoaded){for(c=0;c<b.entries.times.length;c++){if(d.mediaElement.currentTime>=b.entries.times[c].start&&d.mediaElement.currentTime<=b.entries.times[c].stop){d.captionsText.html(b.entries.text[c]);d.captionsDisplay.show();return}}d.captionsDisplay.hide()}else{d.captionsDisplay.hide()}},displayChapters:function(){var c=this,b;for(b=0;b<c.tracks.length;b++){if(c.tracks[b].kind=="chapters"){c.buildChapters(c.tracks[b]);break}}},buildChapters:function(f){var c=this,b,e,d,g;c.chapters.empty();for(b=0;b<f.entries.times.length;b++){e=f.entries.times[b].stop-f.entries.times[b].start;d=Math.floor(c.width*e/c.mediaElement.duration);g=Math.floor(c.width*f.entries.times[b].start/c.mediaElement.duration);if(g+d>c.width){d=c.width-g}c.chapters.append(a('<div class="mep-chapter" rel="'+f.entries.times[b].start+'" style="left: '+g.toString()+"px;width: "+d.toString()+'px;"><div class="mep-chapter-block'+((b==f.entries.times.length-1)?" mep-chapter-block-last":"")+'"><span class="ch-title">'+f.entries.text[b]+'</span><span class="ch-time">'+mejs.Utility.secondsToTimeCode(f.entries.times[b].start)+"&ndash;"+mejs.Utility.secondsToTimeCode(f.entries.times[b].stop)+"</span></div></div>"))}c.chapters.find("div.mep-chapter").click(function(){c.mediaElement.setCurrentTime(parseFloat(a(this).attr("rel")));if(c.mediaElement.paused){c.mediaElement.play()}})},buildPoster:function(){var b=this;b.poster=b.container.find(".mep-poster");b.posterImg=b.poster.find("img");b.posterUrl=b.$media.attr("poster");b.posterUrl=(b.posterUrl===null||b.posterUrl==undefined)?"":b.posterUrl;if(b.posterUrl!==""){b.posterImg.attr("src",b.posterUrl)}else{b.poster.hide()}},buildOverlay:function(){var b=this;b.overlay=b.container.find(".mep-overlay");b.overlay.bind("click",function(c){if(b.mediaElement.paused){b.mediaElement.play()}});b.overlay.hide()},buildControls:function(){var b=this;b.controls=b.container.find(".mep-controls");b.isControlsVisible=true;b.playpause=b.controls.find(".mep-playpause-button");b.fullscreen=b.controls.find(".mep-fullscreen-button");if(!b.isVideo){b.fullscreen.remove()}b.time=b.controls.find(".mep-time");b.currentTime=b.controls.find(".mep-currenttime").html("00:00");b.duration=b.controls.find(".mep-duration").html("00:00");b.captions=b.controls.find(".mep-captions-button");b.mute=b.controls.find(".mep-volume-button");b.volumeSlider=b.controls.find(".mep-volume-slider");b.volumeRail=b.controls.find(".mep-volume-rail");b.volumeHandle=b.controls.find(".mep-volume-handle");b.timeRail=b.controls.find(".mep-time-rail");b.timeCurrent=b.timeRail.find(".mep-time-current").width(0);b.timeLoaded=b.timeRail.find(".mep-time-loaded").width(0);b.timeTotal=b.timeRail.find(".mep-time-total");b.timeHandle=b.controls.find(".mep-time-handle");b.controls.show();b.setRailSize();b.controls.hide();if(!b.options.controls.playpause){b.playpause.remove()}if(!b.options.controls.timerail){b.timeRail.remove()}if(!b.options.controls.duration){b.time.remove()}if(!b.options.controls.volume){b.mute.remove()}if(!b.options.controls.fullscreen){b.fullscreen.remove()}},buildControlBar:function(){var b=this;b.controls.show();if(b.isVideo){b.container.bind("mouseenter",function(){b.controls.css("visibility","visible");b.controls.fadeIn(200);b.captionsDisplay.css("padding-bottom",b.controls.height()+5);b.setRailSize();b.isControlsVisible=true;b.chapters.css("visibility","visible");b.chapters.fadeIn(200)}).bind("mouseleave",function(){if(!b.mediaElement.paused){b.controls.fadeOut(200,function(){a(this).css("visibility","hidden");a(this).css("display","block");b.captionsDisplay.css("padding-bottom",10)});b.isControlsVisible=false;b.chapters.fadeOut(200,function(){a(this).css("visibility","hidden");a(this).css("display","block")})}})}},buildPlayPause:function(){var b=this;b.playpause.bind("click",function(){if(b.playpause.hasClass("mep-play")){b.mediaElement.play();b.playpause.removeClass("mep-play").addClass("mep-pause")}else{b.mediaElement.pause();b.playpause.removeClass("mep-pause").addClass("mep-play")}})},buildTimeRail:function(){var b=this;b.timeRail.delegate("span","click",function(h){var c=h.pageX,i=b.timeTotal.offset(),f=b.timeTotal.outerWidth(),d=((c-i.left)/f),g=d*b.mediaElement.duration;b.mediaElement.setCurrentTime(g)});b.mediaElement.addEventListener("timeupdate",function(c){b.displayCaptions();b.setTimePosition();b.setTimeLoaded(c.target)},true);b.mediaElement.addEventListener("progress",function(c){b.setTimeLoaded(c.target)},true)},setTimePosition:function(){var b=this,d,c;if(b.mediaElement.currentTime&&b.mediaElement.duration){b.currentTime.html(mejs.Utility.secondsToTimeCode(b.mediaElement.currentTime));if(b.mediaElement.duration){b.duration.html(mejs.Utility.secondsToTimeCode(b.mediaElement.duration))}d=b.timeTotal.width()*b.mediaElement.currentTime/b.mediaElement.duration;c=d-(b.timeHandle.width()/2);b.timeCurrent.width(d);b.timeHandle.css("left",c)}},setTimeLoaded:function(d){var b=this,c=null;if(d&&d.bytesTotal!=undefined&&d.bytesTotal>0&&d.bufferedBytes!=undefined){c=d.bufferedBytes/d.bytesTotal}else{if(d&&d.buffered&&d.buffered.length>0&&d.buffered.end&&d.duration){c=d.buffered.end(0)/d.duration}}if(c!==null){b.timeLoaded.width(b.timeTotal.width()*c)}},setRailSize:function(){var b=this,c=b.playpause.outerWidth(true)+b.time.outerWidth(true)+b.mute.outerWidth(true)+b.captions.outerWidth(true)+((b.isVideo)?b.fullscreen.outerWidth(true):0),d=b.controls.width()-c-(b.timeRail.outerWidth(true)-b.timeRail.outerWidth(false));b.timeRail.width(d);b.timeTotal.width(d-(b.timeTotal.outerWidth(true)-b.timeTotal.width()))},setPlayerSize:function(d,b){var c=this;c.width=parseInt(d,10);c.height=parseInt(b,10);c.container.width(c.width).height(c.height);c.captionsDisplay.width(c.width);c.overlay.width(c.width).height(c.height);c.posterImg.height(c.height).width(c.width)},handleError:function(c){var b=this;b.$media.hide();b.overlay.hide();b.controls.hide();b.poster.hide()},buildFullscreen:function(){var b=this;b.isFullScreen=false;b.normalHeight=0;b.normalWidth=0;b.fullscreen.bind("click",function(){b.setFullScreen(!b.isFullScreen)})},setFullScreen:function(b){var c=this;switch(c.mediaElement.pluginType){case"flash":c.mediaElement.setFullscreen(b);break;case"silverlight":c.mediaElement.setFullscreen(b);break;case"native":if(mejs.MediaFeatures.hasNativeFullScreen){if(b){c.mediaElement.webkitEnterFullScreen()}else{c.mediaElement.webkitExitFullScreen()}}else{if(b){c.normalHeight=c.$media.height();c.normalWidth=c.$media.width();c.container.addClass("mep-container-fullscreen").width("100%").height("100%").css("z-index",1000);c.$media.width("100%").height("100%");c.captionsDisplay.width("100%");c.overlay.width("100%").height("100%");c.posterImg.width("100%").height("auto");c.fullscreen.removeClass("mep-fullscreen").addClass("mep-unfullscreen");c.setRailSize();c.escB=function(d){c.escListener(d)};c.resB=function(d){c.resizeListener(d)};a(document).bind("keydown",c.escB);a(window).bind("resize",c.resB)}else{c.container.removeClass("mep-container-fullscreen").width(c.normalWidth).height(c.normalHeight).css("z-index",1);c.$media.width(c.normalWidth).height(c.normalHeight);c.posterImg.width(c.normalWidth).height(c.normalHeight);c.captionsDisplay.width(c.normalWidth);c.fullscreen.removeClass("mep-unfullscreen").addClass("mep-fullscreen");c.setRailSize();a(document).unbind("keydown",c.escB);a(window).unbind("resize",c.resB)}}}c.isFullScreen=b},escListener:function(b){if(b.keyCode==27){this.setFullScreen(false)}},resizeListener:function(b){this.setRailSize()},buildVolumeControls:function(){var b=this;b.vmmB=function(c){b.volumeMove(c)};b.vrmB=function(c){b.removeMouseMove(c)};b.volumeSlider.bind("mousedown",function(c){b.volumeMove(c);a(document).bind("mousemove",b.vmmB).bind("mouseup",b.vrmB)});b.mute.find("span").bind("click",function(){if(b.mediaElement.muted){b.mediaElement.setMuted(false);b.mute.removeClass("mep-unmute").addClass("mep-mute");b.positionVolumeHandle(1)}else{b.mediaElement.setMuted(true);b.mute.removeClass("mep-mute").addClass("mep-unmute");b.positionVolumeHandle(0)}});b.mediaElement.addEventListener("volumechange",function(c){b.positionVolumeHandle(c.target.volume)},true);b.mediaElement.setVolume(b.options.startVolume)},volumeMove:function(g){var c=this,b=c.volumeRail.height(),f=g.pageY-c.volumeRail.offset().top,d=(b-f)/b;if(f<0){f=0}else{if(f>b){f=b}}c.volumeHandle.css("top",f-(c.volumeHandle.height()/2));if(d==0){c.mediaElement.setMuted(true);c.mute.removeClass("mep-mute").addClass("mep-unmute")}else{c.mediaElement.setMuted(false);c.mute.removeClass("mep-unmute").addClass("mep-mute")}c.mediaElement.setVolume(d)},positionVolumeHandle:function(c){var b=this;b.volumeHandle.css("top",b.volumeRail.height()-(b.volumeRail.height()*c)-(b.volumeHandle.height()/2))},removeMouseMove:function(){var b=this;a(document).unbind("mousemove",b.vmmB).unbind("mouseup",b.vrmB)}};mejs.language={codes:{af:"Afrikaans",sq:"Albanian",ar:"Arabic",be:"Belarusian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese","zh-cn":"Chinese Simplified","zh-tw":"Chinese Traditional",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",tl:"Filipino",fi:"Finnish",fr:"French",gl:"Galician",de:"German",el:"Greek",ht:"Haitian Creole",iw:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese",ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",mt:"Maltese",no:"Norwegian",fa:"Persian",pl:"Polish",pt:"Portuguese",ro:"Romanian",ru:"Russian",sr:"Serbian",sk:"Slovak",sl:"Slovenian",es:"Spanish",sw:"Swahili",sv:"Swedish",tl:"Tagalog",th:"Thai",tr:"Turkish",uk:"Ukrainian",vi:"Vietnamese",cy:"Welsh",yi:"Yiddish"}};mejs.SrtParser={pattern_identifier:/^[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{3})?)(.*)$/,timecodeToSeconds:function(b){var c=b.split(":");return c[0]*60*60+c[1]*60+parseFloat(c[2].replace(",","."))},split2:function(c,b){return c.split(b)},parse:function(e){var f=0,d=this.split2(e,/\r?\n/),c={text:[],times:[]},b,g;for(;f<d.length;f++){if(this.pattern_identifier.exec(d[f])){f++;b=this.pattern_timecode.exec(d[f]);if(b&&f<d.length){f++;g=d[f];f++;while(d[f]!==""&&f<d.length){g=g+"\n"+d[f];f++}c.text.push(g);c.times.push({start:this.timecodeToSeconds(b[1]),stop:this.timecodeToSeconds(b[3]),settings:b[5]})}}}return c},translateSrt:function(d,j,f,g,h){var b={text:[],times:[]},c,e;this.translateText(d.text.join(" <a></a>"),j,f,g,function(i){c=i.split("<a></a>");for(e=0;e<d.text.length;e++){b.text[e]=c[e];b.times[e]={start:d.times[e].start,stop:d.times[e].stop,settings:d.times[e].settings}}h(b)})},translateText:function(j,f,d,c,i){var l,e=[],h,b=1000,k="",g=function(){if(e.length>0){h=e.shift();mejs.SrtParser.translateChunk(h,f,d,c,function(m){if(m!="undefined"){k+=m}g()})}else{i(k)}};while(j.length>0){if(j.length>b){l=j.lastIndexOf(".",b);e.push(j.substring(0,l));j=j.substring(l+1)}else{e.push(j);j=""}}g()},translateChunk:function(e,g,c,d,f){var b={q:e,langpair:g+"|"+c,v:"1.0"};if(d!==""&&d!==null){b.key=d}a.ajax({url:"https://ajax.googleapis.com/ajax/services/language/translate",data:b,type:"GET",dataType:"jsonp",success:function(h){f(h.responseData.translatedText)},error:function(h){f(null)}})}};if("x\n\ny".split(/\n/gi).length!=3){mejs.SrtParser.split2=function(f,d){var e=[],b="",c;for(c=0;c<f.length;c++){b+=f.substring(c,c+1);if(d.test(b)){e.push(b.replace(d,""));b=""}}e.push(b);return e}}jQuery.fn.mediaelementplayer=function(b){return this.each(function(){return new mejs.MediaElementPlayer(a(this),b)})};window.MediaElementPlayer=mejs.MediaElementPlayer})(jQuery);
View
55 build/mediaelementplayer.css
@@ -90,6 +90,57 @@
.mep-overlay:hover .mep-overlay-button{
background-position: 0 -100px ;
}
+
+.mep-chapters {
+ position: absolute;
+ top: 0;
+ left: 0;
+ -xborder-right: solid 1px #fff;
+ width: 10000px;
+}
+.mep-chapters .mep-chapter {
+ position: absolute;
+ float: left;
+ background: url(background.png);
+ background: rgba(0,0,0,0.8);
+ overflow: hidden;
+ border: 0;
+}
+.mep-chapters .mep-chapter .mep-chapter-block {
+ font-size: 11px;
+ color: #fff;
+ padding: 5px;
+ display: block;
+ border-right: solid 1px #999;
+ border-bottom: solid 1px #999;
+ cursor: pointer;
+}
+.mep-chapters .mep-chapter .mep-chapter-block-last {
+ border-right: none;
+}
+
+.mep-chapters .mep-chapter .mep-chapter-block:hover {
+ background: #333;
+}
+.mep-chapters .mep-chapter .mep-chapter-block .ch-title{
+ font-size: 12px;
+ font-weight: bold;
+ display: block;
+ white-space:nowrap;
+ text-overflow: ellipsis;
+ margin: 0 0 3px 0;
+ line-height: 12px;
+}
+.mep-chapters .mep-chapter .mep-chapter-block .ch-timespan{
+ font-size: 12px;
+ line-height: 12px;
+ margin: 3px 0 4px 0;
+ display: block;
+ white-space:nowrap;
+ text-overflow: ellipsis;
+}
+
+
.mep-captions-layer {
position: absolute;
bottom: 0;
@@ -307,7 +358,9 @@
width: 100px;
float: left;
padding: 4px 0 0 0;
- line-height: 15px;
+ line-height: 15px;
+ font-family: helvetica, arial;
+ font-size: 10px;
}
.mep-controls .mep-captions-button .mep-captions-translations {
View
69 build/mediaelementplayer.js
@@ -283,6 +283,9 @@
}, true);
t.mediaElement.addEventListener('loadedmetadata', function(e) {
+
+ t.displayChapters();
+
// if the <video height> was not set and the options.videoHeight was not set
// then resize to the real dimensions
if (t.isVideo && t.options.videoHeight <= 0 && t.$media[0].getAttribute('height') === null && !isNaN(e.target.videoHeight)) {
@@ -309,6 +312,7 @@
i;
t.captionsDisplay = t.container.find('.mep-captions-layer').hide();
t.captionsText = t.container.find('.mep-captions-text');
+ t.chapters = t.container.find('.mep-chapters');
if (t.options.translationSelector) {
for (i in mejs.language.codes) {
@@ -432,7 +436,7 @@
t.loadTrack(t.trackToLoad);
} else {
// add done?
- t.isLoadingTrack = false;
+ t.isLoadingTrack = false;
}
},
@@ -471,6 +475,10 @@
// parse the loaded file
track.entries = mejs.SrtParser.parse(d);
after();
+
+ if (track.kind == 'chapters' && t.mediaElement.duration > 0) {
+ t.buildChapters(track);
+ }
},
error: function() {
t.loadNextTrack();
@@ -546,6 +554,56 @@
}
},
+ displayChapters: function() {
+ var
+ t = this,
+ i;
+
+ for (i=0; i<t.tracks.length; i++) {
+ if (t.tracks[i].kind == 'chapters') {
+ t.buildChapters(t.tracks[i]);
+ break;
+ }
+ }
+ },
+
+ buildChapters: function(chapters) {
+ var
+ t = this,
+ i,
+ dur,
+ width,
+ left
+ ;
+
+ t.chapters.empty();
+
+ for (i=0; i<chapters.entries.times.length; i++) {
+ dur = chapters.entries.times[i].stop - chapters.entries.times[i].start;
+ //width = length / t.mediaElement.duration * 100;
+ width = Math.floor(t.width * dur / t.mediaElement.duration);
+ left = Math.floor(t.width * chapters.entries.times[i].start / t.mediaElement.duration);
+ if (left + width > t.width) {
+ width = t.width - left;
+ }
+
+ t.chapters.append( $(
+ '<div class="mep-chapter" rel="' + chapters.entries.times[i].start + '" style="left: ' + left.toString() + 'px;width: ' + width.toString() + 'px;">' +
+ '<div class="mep-chapter-block' + ((i==chapters.entries.times.length-1) ? ' mep-chapter-block-last' : '') + '">' +
+ '<span class="ch-title">' + chapters.entries.text[i] + '</span>' +
+ '<span class="ch-time">' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].start) + '&ndash;' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].stop) + '</span>' +
+ '</div>' +
+ '</div>'));
+ }
+
+ t.chapters.find('div.mep-chapter').click(function() {
+ t.mediaElement.setCurrentTime( parseFloat( $(this).attr('rel') ) );
+ if (t.mediaElement.paused) {
+ t.mediaElement.play();
+ }
+ });
+ },
+
buildPoster: function() {
var t = this;
@@ -649,6 +707,10 @@
t.captionsDisplay.css('padding-bottom', t.controls.height() + 5);
t.setRailSize();
t.isControlsVisible = true;
+
+ // chapters
+ t.chapters.css('visibility','visible');
+ t.chapters.fadeIn(200);
})
.bind('mouseleave', function () {
if (!t.mediaElement.paused) {
@@ -658,6 +720,11 @@
t.captionsDisplay.css('padding-bottom', 10);
});
t.isControlsVisible = false;
+
+ t.chapters.fadeOut(200, function() {
+ $(this).css('visibility','hidden');
+ $(this).css('display','block');
+ });
}
});
}
View
2  build/mediaelementplayer.min.css
@@ -1 +1 @@
-.mep-container{position:relative;background:#000;font-family:Helvetica,Arial;}.me-cannotplay a{color:#fff;font-weight:bold;}.me-cannotplay span{padding:15px;display:block;}.mep-container-fullscreen{position:fixed;left:0;top:0;right:0;bottom:0;overflow:hidden;}.mep-container-fullscreen .mep-mediaelement,.mep-container-fullscreen video{width:100%;height:100%;}.mep-mediaelement{position:absolute;top:0;left:0;}.mep-poster{position:absolute;top:0;left:0;}.mep-overlay{position:absolute;top:0;left:0;cursor:pointer;}.mep-overlay-button{position:absolute;top:50%;left:50%;width:100px;height:100px;margin:-50px 0 0 -50px;background:url(bigplay.png) top left no-repeat;}.mep-overlay:hover .mep-overlay-button{background-position:0 -100px;}.mep-captions-layer{position:absolute;bottom:0;left:0;padding:0 0 38px 0;text-align:center;line-height:22px;font-size:12px;color:#fff;}.mep-captions-layer a{color:#fff;text-decoration:underline;}.mep-captions-layer[lang=ar]{font-size:20px;font-weight:normal;}.mep-captions-text{padding:3px 5px;background:url(background.png);background:rgba(0,0,0,0.8);}.mep-container .mep-controls{position:absolute;background:none;list-style-type:none;margin:0;padding:0;bottom:0;left:0;background:url(background.png);background:rgba(0,0,0,0.7);height:30px;width:100%;}.mep-container .mep-controls div{list-style-type:none;background-image:none;display:inline-block;float:left;margin:5px 5px 5px 0;padding:0;width:20px;height:20px;font-size:11px;line-height:11px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;font-family:Helvetica,Arial;}.mep-container .mep-controls div:first-child{margin-left:5px;}.mep-container .mep-controls .mep-time{color:#fff;display:block;width:80px;height:17px;padding:3px 0 0 0;overflow:hidden;text-align:center;}.mep-container .mep-controls .mep-time span{font-size:11px;color:#fff;line-height:1em;display:inline-block;}.mep-controls .mep-playpause-button span,.mep-controls .mep-volume-button span,.mep-controls .mep-fullscreen-button span,.mep-controls .mep-captions-button span{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:2px;height:16px;width:16px;background:transparent url(controls.png) 0 0 no-repeat;}.mep-controls .mep-play span{background-position:0 0;}.mep-controls .mep-pause span{background-position:0 -16px;}.mep-controls .mep-time-rail{width:200px;}.mep-controls .mep-time-rail span{display:block;position:absolute;width:180px;height:10px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;cursor:pointer;}.mep-controls .mep-time-rail .mep-time-total{margin:5px;background:#333;background:rgba(50,50,50,50.8);}.mep-controls .mep-time-rail .mep-time-loaded{background:#3caac8;background:rgba(60,170,200,0.8);}.mep-controls .mep-time-rail .mep-time-current{background:#fff;background:rgba(255,255,255,0.8);}.mep-controls .mep-time-rail .mep-time-handle{display:block;position:absolute;margin:0;width:10px;background:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;cursor:pointer;display:none;}.mep-controls .mep-fullscreen-button span{background-position:-32px 0;}.mep-controls .mep-unfullscreen span{background-position:-32px -16px;}.mep-controls .mep-captions-button{position:relative;}.mep-controls .mep-captions-button span{background-position:-48px 0;}.mep-controls .mep-captions-button .mep-captions-selector{visibility:hidden;position:absolute;bottom:15px;left:-80px;width:130px;min-height:50px;background:url(background.png);background:rgba(0,0,0,0.8);border:solid 1px #fff;padding:10px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.mep-controls .mep-captions-button:hover .mep-captions-selector{visibility:visible;}.mep-controls .mep-captions-button .mep-captions-selector ul{margin:0;padding:0;display:block;list-style-type:none!important;overflow:hidden;}.mep-controls .mep-captions-button .mep-captions-selector ul li{margin:0 0 6px 0;padding:0;list-style-type:none!important;display:block;color:#fff;overflow:hidden;}.mep-controls .mep-captions-button .mep-captions-selector ul li input{clear:both;float:left;}.mep-controls .mep-captions-button .mep-captions-selector ul li label{width:100px;float:left;padding:4px 0 0 0;line-height:15px;}.mep-controls .mep-captions-button .mep-captions-translations{font-size:10px;margin:0 0 5px 0;}.mep-controls .mep-mute span{background-position:-16px -16px;}.mep-controls .mep-unmute span{background-position:-16px 0;}.mep-controls .mep-volume-button{position:relative;}.mep-controls .mep-volume-button .mep-volume-slider{display:none;height:115px;width:20px;background:url(background.png);background:rgba(0,0,0,0.7);-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;top:-115px;left:0;z-index:1;position:absolute;margin:0;}.mep-controls .mep-volume-button:hover{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}.mep-controls .mep-volume-button:hover .mep-volume-slider{display:block;}.mep-controls .mep-volume-button .mep-volume-slider .mep-volume-rail{position:absolute;left:9px;top:8px;width:2px;height:100px;background:#ddd;background:rgba(255,255,255,0.8);margin:0;}.mep-controls .mep-volume-button .mep-volume-slider .mep-volume-rail .mep-volume-handle{position:absolute;left:-7px;top:-3px;width:16px;height:6px;background:#ddd;background:rgba(255,255,255,0.9);cursor:N-resize;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;margin:0;}.mep-clear{clear:both;}
+.mep-container{position:relative;background:#000;font-family:Helvetica,Arial;}.me-cannotplay a{color:#fff;font-weight:bold;}.me-cannotplay span{padding:15px;display:block;}.mep-container-fullscreen{position:fixed;left:0;top:0;right:0;bottom:0;overflow:hidden;}.mep-container-fullscreen .mep-mediaelement,.mep-container-fullscreen video{width:100%;height:100%;}.mep-mediaelement{position:absolute;top:0;left:0;}.mep-poster{position:absolute;top:0;left:0;}.mep-overlay{position:absolute;top:0;left:0;cursor:pointer;}.mep-overlay-button{position:absolute;top:50%;left:50%;width:100px;height:100px;margin:-50px 0 0 -50px;background:url(bigplay.png) top left no-repeat;}.mep-overlay:hover .mep-overlay-button{background-position:0 -100px;}.mep-chapters{position:absolute;top:0;left:0;-xborder-right:solid 1px #fff;width:10000px;}.mep-chapters .mep-chapter{position:absolute;float:left;background:url(background.png);background:rgba(0,0,0,0.8);overflow:hidden;border:0;}.mep-chapters .mep-chapter .mep-chapter-block{font-size:11px;color:#fff;padding:5px;display:block;border-right:solid 1px #999;border-bottom:solid 1px #999;cursor:pointer;}.mep-chapters .mep-chapter .mep-chapter-block-last{border-right:none;}.mep-chapters .mep-chapter .mep-chapter-block:hover{background:#333;}.mep-chapters .mep-chapter .mep-chapter-block .ch-title{font-size:12px;font-weight:bold;display:block;white-space:nowrap;text-overflow:ellipsis;margin:0 0 3px 0;line-height:12px;}.mep-chapters .mep-chapter .mep-chapter-block .ch-timespan{font-size:12px;line-height:12px;margin:3px 0 4px 0;display:block;white-space:nowrap;text-overflow:ellipsis;}.mep-captions-layer{position:absolute;bottom:0;left:0;padding:0 0 38px 0;text-align:center;line-height:22px;font-size:12px;color:#fff;}.mep-captions-layer a{color:#fff;text-decoration:underline;}.mep-captions-layer[lang=ar]{font-size:20px;font-weight:normal;}.mep-captions-text{padding:3px 5px;background:url(background.png);background:rgba(0,0,0,0.8);}.mep-container .mep-controls{position:absolute;background:none;list-style-type:none;margin:0;padding:0;bottom:0;left:0;background:url(background.png);background:rgba(0,0,0,0.7);height:30px;width:100%;}.mep-container .mep-controls div{list-style-type:none;background-image:none;display:inline-block;float:left;margin:5px 5px 5px 0;padding:0;width:20px;height:20px;font-size:11px;line-height:11px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;font-family:Helvetica,Arial;}.mep-container .mep-controls div:first-child{margin-left:5px;}.mep-container .mep-controls .mep-time{color:#fff;display:block;width:80px;height:17px;padding:3px 0 0 0;overflow:hidden;text-align:center;}.mep-container .mep-controls .mep-time span{font-size:11px;color:#fff;line-height:1em;display:inline-block;}.mep-controls .mep-playpause-button span,.mep-controls .mep-volume-button span,.mep-controls .mep-fullscreen-button span,.mep-controls .mep-captions-button span{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:2px;height:16px;width:16px;background:transparent url(controls.png) 0 0 no-repeat;}.mep-controls .mep-play span{background-position:0 0;}.mep-controls .mep-pause span{background-position:0 -16px;}.mep-controls .mep-time-rail{width:200px;}.mep-controls .mep-time-rail span{display:block;position:absolute;width:180px;height:10px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;cursor:pointer;}.mep-controls .mep-time-rail .mep-time-total{margin:5px;background:#333;background:rgba(50,50,50,50.8);}.mep-controls .mep-time-rail .mep-time-loaded{background:#3caac8;background:rgba(60,170,200,0.8);}.mep-controls .mep-time-rail .mep-time-current{background:#fff;background:rgba(255,255,255,0.8);}.mep-controls .mep-time-rail .mep-time-handle{display:block;position:absolute;margin:0;width:10px;background:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;cursor:pointer;display:none;}.mep-controls .mep-fullscreen-button span{background-position:-32px 0;}.mep-controls .mep-unfullscreen span{background-position:-32px -16px;}.mep-controls .mep-captions-button{position:relative;}.mep-controls .mep-captions-button span{background-position:-48px 0;}.mep-controls .mep-captions-button .mep-captions-selector{visibility:hidden;position:absolute;bottom:15px;left:-80px;width:130px;min-height:50px;background:url(background.png);background:rgba(0,0,0,0.8);border:solid 1px #fff;padding:10px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.mep-controls .mep-captions-button:hover .mep-captions-selector{visibility:visible;}.mep-controls .mep-captions-button .mep-captions-selector ul{margin:0;padding:0;display:block;list-style-type:none!important;overflow:hidden;}.mep-controls .mep-captions-button .mep-captions-selector ul li{margin:0 0 6px 0;padding:0;list-style-type:none!important;display:block;color:#fff;overflow:hidden;}.mep-controls .mep-captions-button .mep-captions-selector ul li input{clear:both;float:left;}.mep-controls .mep-captions-button .mep-captions-selector ul li label{width:100px;float:left;padding:4px 0 0 0;line-height:15px;font-family:helvetica,arial;font-size:10px;}.mep-controls .mep-captions-button .mep-captions-translations{font-size:10px;margin:0 0 5px 0;}.mep-controls .mep-mute span{background-position:-16px -16px;}.mep-controls .mep-unmute span{background-position:-16px 0;}.mep-controls .mep-volume-button{position:relative;}.mep-controls .mep-volume-button .mep-volume-slider{display:none;height:115px;width:20px;background:url(background.png);background:rgba(0,0,0,0.7);-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;top:-115px;left:0;z-index:1;position:absolute;margin:0;}.mep-controls .mep-volume-button:hover{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}.mep-controls .mep-volume-button:hover .mep-volume-slider{display:block;}.mep-controls .mep-volume-button .mep-volume-slider .mep-volume-rail{position:absolute;left:9px;top:8px;width:2px;height:100px;background:#ddd;background:rgba(255,255,255,0.8);margin:0;}.mep-controls .mep-volume-button .mep-volume-slider .mep-volume-rail .mep-volume-handle{position:absolute;left:-7px;top:-3px;width:16px;height:6px;background:#ddd;background:rgba(255,255,255,0.9);cursor:N-resize;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;margin:0;}.mep-clear{clear:both;}
View
2  build/mediaelementplayer.min.js
@@ -10,4 +10,4 @@
*
* Version: 1.1.3
*/
-(function(a){mejs.MepDefaults={defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,audioWidth:300,audioHeight:30,startVolume:0.8,loop:false,startLanguage:"",translations:[],translationSelector:false,googleApiKey:"",controls:{playpause:true,timerail:true,duration:true,volume:true,captions:true,fullscreen:true},controlsTemplate:'<div class="mep-playpause-button mep-play"><span></span></div><div class="mep-time-rail"><span class="mep-time-total"><span class="mep-time-loaded"></span><span class="mep-time-current"></span><span class="mep-time-handle"></span></span></div><div class="mep-time"><span class="mep-currenttime"></span><span>&nbsp;|&nbsp;</span><span class="mep-duration"></span></div><div class="mep-captions-button"><span></span><div class="mep-captions-selector"><ul></ul></div></div><div class="mep-volume-button mep-mute"><span></span><div class="mep-volume-slider"><div class="mep-volume-rail"><div class="mep-volume-handle"></div></div></div></div><div class="mep-fullscreen-button"><span></span></div>'};mejs.mepIndex=0;mejs.MediaElementPlayer=function(d,e){var b=this,c=mejs.MediaFeatures;b.$media=a(d);b.options=a.extend(true,{},mejs.MepDefaults,e);b.isVideo=(b.$media[0].tagName.toLowerCase()=="video");if(c.isiPad||c.isiPhone){b.$media.attr("controls","controls");b.$media.removeAttr("poster");if(c.isiPad&&b.$media[0].getAttribute("autoplay")!==null){b.$media[0].load();b.$media[0].play()}return}else{if(c.isAndroid&&b.isVideo){b.$media.attr("controls","controls");return}else{b.$media.removeAttr("controls")}}b.createPlayer()};mejs.MediaElementPlayer.prototype={createPlayer:function(){var b=this,c=a.extend(true,{},b.options,{success:function(d,e){b.setupPlayer(d,e)},error:function(d){b.handleError(d)}});b.id="mep_"+mejs.mepIndex++;b.$media.before(a('<div id="'+b.id+'" class="mep-container"><div class="mep-mediaelement"></div><div class="mep-captions-layer"><span class="mep-captions-text"></span></div><div class="mep-poster"><img /></div><div class="mep-overlay"><div class="mep-overlay-button"></div></div><div class="mep-chapters"></div><div class="mep-controls">'+b.options.controlsTemplate+'</div><div class="mep-clear"></div></div>'));b.container=a("#"+this.id);b.container.find(".mep-captions-selector ul").append(a('<li><input type="radio" name="'+this.id+'_captions" id="'+this.id+'_captions_none" value="none" checked="checked" /><label for="'+this.id+'_captions_none">None</label></li>'));b.container.addClass(b.$media[0].className).find(".mep-mediaelement").append(b.$media);if(b.isVideo){b.width=(b.options.videoWidth>0)?b.options.videoWidth:(b.$media[0].getAttribute("width")!==null)?b.$media.attr("width"):b.options.defaultVideoWidth;b.height=(b.options.videoHeight>0)?b.options.videoHeight:(b.$media[0].getAttribute("height")!==null)?b.$media.attr("height"):b.options.defaultVideoHeight}else{b.width=b.options.audioWidth;b.height=b.options.audioHeight}b.buildPoster();b.buildOverlay();b.buildCaptionsDisplay();b.setPlayerSize(b.width,b.height);b.buildControls();c.pluginWidth=b.height;c.pluginHeight=b.width;mejs.MediaElement(b.$media[0],c)},setupPlayer:function(b,d){var c=this;c.mediaElement=b;c.domNode=d;if(c.isVideo){c.overlay.show()}c.buildControlBar();c.buildPlayPause();c.buildTimeRail();c.buildVolumeControls();c.buildCaptionsControls();c.buildFullscreen();c.mediaElement.addEventListener("click",function(f){if(c.mediaElement.paused){c.mediaElement.play()}},true);c.mediaElement.addEventListener("play",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("playing",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("pause",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("paused",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("ended",function(f){c.mediaElement.setCurrentTime(0);c.mediaElement.pause();if(c.options.loop){c.mediaElement.play()}else{c.poster.show();c.overlay.show();c.controls.css("visibility","visible");c.playpause.removeClass("mep-pause").addClass("mep-play");c.setTimePosition()}},true);c.mediaElement.addEventListener("loadedmetadata",function(f){if(c.isVideo&&c.options.videoHeight<=0&&c.$media[0].getAttribute("height")===null&&!isNaN(f.target.videoHeight)){c.setPlayerSize(f.target.videoWidth,f.target.videoHeight);c.setRailSize();c.mediaElement.setVideoSize(f.target.videoWidth,f.target.videoHeight)}},true);setTimeout(function(){c.setRailSize()},50);if(c.options.success){c.options.success(c.mediaElement,c.domNode)}this.findTracks()},buildCaptionsDisplay:function(){var d=this,b="",c;d.captionsDisplay=d.container.find(".mep-captions-layer").hide();d.captionsText=d.container.find(".mep-captions-text");if(d.options.translationSelector){for(c in mejs.language.codes){b+='<option value="'+c+'">'+mejs.language.codes[c]+"</option>"}d.container.find(".mep-captions-selector ul").before(a('<select class="mep-captions-translations"><option value="">--Add Translation--</option>'+b+"</select>"));d.container.find(".mep-captions-translations").change(function(){var e=a(this);lang=e.val();if(lang!=""){d.tracks.push({srclang:lang,src:null,entries:[],isLoaded:false,isTranslation:true});if(!d.isLoadingTrack){d.trackToLoad--;d.addTrackButton(lang,true);d.options.startLanguage=lang;d.loadNextTrack()}}})}},buildCaptionsControls:function(){var c=this,d,b;c.captions.delegate("input[type=radio]","click",function(){d=this.value;if(d=="none"){c.selectedTrack=null}else{for(b=0;b<c.tracks.length;b++){if(c.tracks[b].srclang==d){c.selectedTrack=c.tracks[b];c.captionsDisplay.attr("lang",c.selectedTrack.srclang);c.displayCaptions();break}}}})},findTracks:function(){var c=this,b,d=c.$media.find("track");c.tracks=[];c.trackToLoad=-1;c.selectedTrack=null;c.isLoadingTrack=false;d.each(function(){c.tracks.push({srclang:a(this).attr("srclang").toLowerCase(),src:a(this).attr("src"),kind:a(this).attr("kind"),entries:[],isLoaded:false,isTranslation:false})});if(c.tracks.length>0&&c.options.translations.length>0){for(b=0;b<c.options.translations.length;b++){c.tracks.push({srclang:c.options.translations[b].toLowerCase(),src:null,kind:"subtitles",entries:[],isLoaded:false,isTranslation:true})}}for(b=0;b<c.tracks.length;b++){if(c.tracks[b].kind=="subtitles"){c.addTrackButton(c.tracks[b].srclang,c.tracks[b].isTranslation)}}if(c.tracks.length>0){c.loadNextTrack()}else{c.captions.remove();c.setRailSize()}},loadNextTrack:function(){var b=this;b.trackToLoad++;if(b.trackToLoad<b.tracks.length){b.isLoadingTrack=true;b.loadTrack(b.trackToLoad)}else{b.isLoadingTrack=false}},loadTrack:function(c){var d=this,b=d.tracks[c],e=function(){b.isLoaded=true;d.enableTrackButton(b.srclang);d.loadNextTrack()};if(b.isTranslation){mejs.SrtParser.translateSrt(d.tracks[0].entries,d.tracks[0].srclang,b.srclang,d.options.googleApiKey,function(f){b.entries=f;e()})}else{a.ajax({url:b.src,success:function(f){b.entries=mejs.SrtParser.parse(f);e()},error:function(){d.loadNextTrack()}})}},enableTrackButton:function(c){var b=this;b.captions.find("input[value="+c+"]").attr("disabled","").siblings("label").html(mejs.language.codes[c]||c);if(b.options.startLanguage==c){a("#"+b.id+"_captions_"+c).click()}b.adjustLanguageBox()},addTrackButton:function(e,d){var c=this,b=mejs.language.codes[e]||e;c.captions.find("ul").append(a('<li><input type="radio" name="'+c.id+'_captions" id="'+c.id+"_captions_"+e+'" value="'+e+'" disabled="disabled" /><label for="'+c.id+"_captions_"+e+'">'+b+((d)?" (translating)":" (loading)")+"</label></li>"));c.adjustLanguageBox();c.container.find(".mep-captions-translations option[value="+e+"]").remove()},adjustLanguageBox:function(){var b=this;b.captions.find(".mep-captions-selector").height(b.captions.find(".mep-captions-selector ul").outerHeight(true)+b.captions.find(".mep-captions-translations").outerHeight(true))},displayCaptions:function(){if(typeof this.tracks=="undefined"){return}var d=this,c,b=d.selectedTrack;if(b!=null&&b.isLoaded){for(c=0;c<b.entries.times.length;c++){if(d.mediaElement.currentTime>=b.entries.times[c].start&&d.mediaElement.currentTime<=b.entries.times[c].stop){d.captionsText.html(b.entries.text[c]);d.captionsDisplay.show();return}}d.captionsDisplay.hide()}else{d.captionsDisplay.hide()}},buildPoster:function(){var b=this;b.poster=b.container.find(".mep-poster");b.posterImg=b.poster.find("img");b.posterUrl=b.$media.attr("poster");b.posterUrl=(b.posterUrl===null||b.posterUrl==undefined)?"":b.posterUrl;if(b.posterUrl!==""){b.posterImg.attr("src",b.posterUrl)}else{b.poster.hide()}},buildOverlay:function(){var b=this;b.overlay=b.container.find(".mep-overlay");b.overlay.bind("click",function(c){if(b.mediaElement.paused){b.mediaElement.play()}});b.overlay.hide()},buildControls:function(){var b=this;b.controls=b.container.find(".mep-controls");b.isControlsVisible=true;b.playpause=b.controls.find(".mep-playpause-button");b.fullscreen=b.controls.find(".mep-fullscreen-button");if(!b.isVideo){b.fullscreen.remove()}b.time=b.controls.find(".mep-time");b.currentTime=b.controls.find(".mep-currenttime").html("00:00");b.duration=b.controls.find(".mep-duration").html("00:00");b.captions=b.controls.find(".mep-captions-button");b.mute=b.controls.find(".mep-volume-button");b.volumeSlider=b.controls.find(".mep-volume-slider");b.volumeRail=b.controls.find(".mep-volume-rail");b.volumeHandle=b.controls.find(".mep-volume-handle");b.timeRail=b.controls.find(".mep-time-rail");b.timeCurrent=b.timeRail.find(".mep-time-current").width(0);b.timeLoaded=b.timeRail.find(".mep-time-loaded").width(0);b.timeTotal=b.timeRail.find(".mep-time-total");b.timeHandle=b.controls.find(".mep-time-handle");b.controls.show();b.setRailSize();b.controls.hide();if(!b.options.controls.playpause){b.playpause.remove()}if(!b.options.controls.timerail){b.timeRail.remove()}if(!b.options.controls.duration){b.time.remove()}if(!b.options.controls.volume){b.mute.remove()}if(!b.options.controls.fullscreen){b.fullscreen.remove()}},buildControlBar:function(){var b=this;b.controls.show();if(b.isVideo){b.container.bind("mouseenter",function(){b.controls.css("visibility","visible");b.controls.fadeIn(200);b.captionsDisplay.css("padding-bottom",b.controls.height()+5);b.setRailSize();b.isControlsVisible=true}).bind("mouseleave",function(){if(!b.mediaElement.paused){b.controls.fadeOut(200,function(){a(this).css("visibility","hidden");a(this).css("display","block");b.captionsDisplay.css("padding-bottom",10)});b.isControlsVisible=false}})}},buildPlayPause:function(){var b=this;b.playpause.bind("click",function(){if(b.playpause.hasClass("mep-play")){b.mediaElement.play();b.playpause.removeClass("mep-play").addClass("mep-pause")}else{b.mediaElement.pause();b.playpause.removeClass("mep-pause").addClass("mep-play")}})},buildTimeRail:function(){var b=this;b.timeRail.delegate("span","click",function(h){var c=h.pageX,i=b.timeTotal.offset(),f=b.timeTotal.outerWidth(),d=((c-i.left)/f),g=d*b.mediaElement.duration;b.mediaElement.setCurrentTime(g)});b.mediaElement.addEventListener("timeupdate",function(c){b.displayCaptions();b.setTimePosition();b.setTimeLoaded(c.target)},true);b.mediaElement.addEventListener("progress",function(c){b.setTimeLoaded(c.target)},true)},setTimePosition:function(){var b=this,d,c;if(b.mediaElement.currentTime&&b.mediaElement.duration){b.currentTime.html(mejs.Utility.secondsToTimeCode(b.mediaElement.currentTime));if(b.mediaElement.duration){b.duration.html(mejs.Utility.secondsToTimeCode(b.mediaElement.duration))}d=b.timeTotal.width()*b.mediaElement.currentTime/b.mediaElement.duration;c=d-(b.timeHandle.width()/2);b.timeCurrent.width(d);b.timeHandle.css("left",c)}},setTimeLoaded:function(d){var b=this,c=null;if(d&&d.bytesTotal!=undefined&&d.bytesTotal>0&&d.bufferedBytes!=undefined){c=d.bufferedBytes/d.bytesTotal}else{if(d&&d.buffered&&d.buffered.length>0&&d.buffered.end&&d.duration){c=d.buffered.end(0)/d.duration}}if(c!==null){b.timeLoaded.width(b.timeTotal.width()*c)}},setRailSize:function(){var b=this,c=b.playpause.outerWidth(true)+b.time.outerWidth(true)+b.mute.outerWidth(true)+b.captions.outerWidth(true)+((b.isVideo)?b.fullscreen.outerWidth(true):0),d=b.controls.width()-c-(b.timeRail.outerWidth(true)-b.timeRail.outerWidth(false));b.timeRail.width(d);b.timeTotal.width(d-(b.timeTotal.outerWidth(true)-b.timeTotal.width()))},setPlayerSize:function(d,b){var c=this;c.width=parseInt(d,10);c.height=parseInt(b,10);c.container.width(c.width).height(c.height);c.captionsDisplay.width(c.width);c.overlay.width(c.width).height(c.height);c.posterImg.height(c.height).width(c.width)},handleError:function(c){var b=this;b.$media.hide();b.overlay.hide();b.controls.hide();b.poster.hide()},buildFullscreen:function(){var b=this;b.isFullScreen=false;b.normalHeight=0;b.normalWidth=0;b.fullscreen.bind("click",function(){b.setFullScreen(!b.isFullScreen)})},setFullScreen:function(b){var c=this;switch(c.mediaElement.pluginType){case"flash":c.mediaElement.setFullscreen(b);break;case"silverlight":c.mediaElement.setFullscreen(b);break;case"native":if(mejs.MediaFeatures.hasNativeFullScreen){if(b){c.mediaElement.webkitEnterFullScreen()}else{c.mediaElement.webkitExitFullScreen()}}else{if(b){c.normalHeight=c.$media.height();c.normalWidth=c.$media.width();c.container.addClass("mep-container-fullscreen").width("100%").height("100%").css("z-index",1000);c.$media.width("100%").height("100%");c.captionsDisplay.width("100%");c.overlay.width("100%").height("100%");c.posterImg.width("100%").height("auto");c.fullscreen.removeClass("mep-fullscreen").addClass("mep-unfullscreen");c.setRailSize();c.escB=function(d){c.escListener(d)};c.resB=function(d){c.resizeListener(d)};a(document).bind("keydown",c.escB);a(window).bind("resize",c.resB)}else{c.container.removeClass("mep-container-fullscreen").width(c.normalWidth).height(c.normalHeight).css("z-index",1);c.$media.width(c.normalWidth).height(c.normalHeight);c.posterImg.width(c.normalWidth).height(c.normalHeight);c.captionsDisplay.width(c.normalWidth);c.fullscreen.removeClass("mep-unfullscreen").addClass("mep-fullscreen");c.setRailSize();a(document).unbind("keydown",c.escB);a(window).unbind("resize",c.resB)}}}c.isFullScreen=b},escListener:function(b){if(b.keyCode==27){this.setFullScreen(false)}},resizeListener:function(b){this.setRailSize()},buildVolumeControls:function(){var b=this;b.vmmB=function(c){b.volumeMove(c)};b.vrmB=function(c){b.removeMouseMove(c)};b.volumeSlider.bind("mousedown",function(c){b.volumeMove(c);a(document).bind("mousemove",b.vmmB).bind("mouseup",b.vrmB)});b.mute.find("span").bind("click",function(){if(b.mediaElement.muted){b.mediaElement.setMuted(false);b.mute.removeClass("mep-unmute").addClass("mep-mute");b.positionVolumeHandle(1)}else{b.mediaElement.setMuted(true);b.mute.removeClass("mep-mute").addClass("mep-unmute");b.positionVolumeHandle(0)}});b.mediaElement.addEventListener("volumechange",function(c){b.positionVolumeHandle(c.target.volume)},true);b.mediaElement.setVolume(b.options.startVolume)},volumeMove:function(g){var c=this,b=c.volumeRail.height(),f=g.pageY-c.volumeRail.offset().top,d=(b-f)/b;if(f<0){f=0}else{if(f>b){f=b}}c.volumeHandle.css("top",f-(c.volumeHandle.height()/2));if(d==0){c.mediaElement.setMuted(true);c.mute.removeClass("mep-mute").addClass("mep-unmute")}else{c.mediaElement.setMuted(false);c.mute.removeClass("mep-unmute").addClass("mep-mute")}c.mediaElement.setVolume(d)},positionVolumeHandle:function(c){var b=this;b.volumeHandle.css("top",b.volumeRail.height()-(b.volumeRail.height()*c)-(b.volumeHandle.height()/2))},removeMouseMove:function(){var b=this;a(document).unbind("mousemove",b.vmmB).unbind("mouseup",b.vrmB)}};mejs.language={codes:{af:"Afrikaans",sq:"Albanian",ar:"Arabic",be:"Belarusian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese","zh-cn":"Chinese Simplified","zh-tw":"Chinese Traditional",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",tl:"Filipino",fi:"Finnish",fr:"French",gl:"Galician",de:"German",el:"Greek",ht:"Haitian Creole",iw:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese",ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",mt:"Maltese",no:"Norwegian",fa:"Persian",pl:"Polish",pt:"Portuguese",ro:"Romanian",ru:"Russian",sr:"Serbian",sk:"Slovak",sl:"Slovenian",es:"Spanish",sw:"Swahili",sv:"Swedish",tl:"Tagalog",th:"Thai",tr:"Turkish",uk:"Ukrainian",vi:"Vietnamese",cy:"Welsh",yi:"Yiddish"}};mejs.SrtParser={pattern_identifier:/^[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{3})?)(.*)$/,timecodeToSeconds:function(b){var c=b.split(":");return c[0]*60*60+c[1]*60+parseFloat(c[2].replace(",","."))},split2:function(c,b){return c.split(b)},parse:function(e){var f=0,d=this.split2(e,/\r?\n/),c={text:[],times:[]},b,g;for(;f<d.length;f++){if(this.pattern_identifier.exec(d[f])){f++;b=this.pattern_timecode.exec(d[f]);if(b&&f<d.length){f++;g=d[f];f++;while(d[f]!==""&&f<d.length){g=g+"\n"+d[f];f++}c.text.push(g);c.times.push({start:this.timecodeToSeconds(b[1]),stop:this.timecodeToSeconds(b[3]),settings:b[5]})}}}return c},translateSrt:function(d,j,f,g,h){var b={text:[],times:[]},c,e;this.translateText(d.text.join(" <a></a>"),j,f,g,function(i){c=i.split("<a></a>");for(e=0;e<d.text.length;e++){b.text[e]=c[e];b.times[e]={start:d.times[e].start,stop:d.times[e].stop,settings:d.times[e].settings}}h(b)})},translateText:function(j,f,d,c,i){var l,e=[],h,b=1000,k="",g=function(){if(e.length>0){h=e.shift();mejs.SrtParser.translateChunk(h,f,d,c,function(m){if(m!="undefined"){k+=m}g()})}else{i(k)}};while(j.length>0){if(j.length>b){l=j.lastIndexOf(".",b);e.push(j.substring(0,l));j=j.substring(l+1)}else{e.push(j);j=""}}g()},translateChunk:function(e,g,c,d,f){var b={q:e,langpair:g+"|"+c,v:"1.0"};if(d!==""&&d!==null){b.key=d}a.ajax({url:"https://ajax.googleapis.com/ajax/services/language/translate",data:b,type:"GET",dataType:"jsonp",success:function(h){f(h.responseData.translatedText)},error:function(h){f(null)}})}};if("x\n\ny".split(/\n/gi).length!=3){mejs.SrtParser.split2=function(f,d){var e=[],b="",c;for(c=0;c<f.length;c++){b+=f.substring(c,c+1);if(d.test(b)){e.push(b.replace(d,""));b=""}}e.push(b);return e}}jQuery.fn.mediaelementplayer=function(b){return this.each(function(){return new mejs.MediaElementPlayer(a(this),b)})};window.MediaElementPlayer=mejs.MediaElementPlayer})(jQuery);
+(function(a){mejs.MepDefaults={defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,audioWidth:300,audioHeight:30,startVolume:0.8,loop:false,startLanguage:"",translations:[],translationSelector:false,googleApiKey:"",controls:{playpause:true,timerail:true,duration:true,volume:true,captions:true,fullscreen:true},controlsTemplate:'<div class="mep-playpause-button mep-play"><span></span></div><div class="mep-time-rail"><span class="mep-time-total"><span class="mep-time-loaded"></span><span class="mep-time-current"></span><span class="mep-time-handle"></span></span></div><div class="mep-time"><span class="mep-currenttime"></span><span>&nbsp;|&nbsp;</span><span class="mep-duration"></span></div><div class="mep-captions-button"><span></span><div class="mep-captions-selector"><ul></ul></div></div><div class="mep-volume-button mep-mute"><span></span><div class="mep-volume-slider"><div class="mep-volume-rail"><div class="mep-volume-handle"></div></div></div></div><div class="mep-fullscreen-button"><span></span></div>'};mejs.mepIndex=0;mejs.MediaElementPlayer=function(d,e){var b=this,c=mejs.MediaFeatures;b.$media=a(d);b.options=a.extend(true,{},mejs.MepDefaults,e);b.isVideo=(b.$media[0].tagName.toLowerCase()=="video");if(c.isiPad||c.isiPhone){b.$media.attr("controls","controls");b.$media.removeAttr("poster");if(c.isiPad&&b.$media[0].getAttribute("autoplay")!==null){b.$media[0].load();b.$media[0].play()}return}else{if(c.isAndroid&&b.isVideo){b.$media.attr("controls","controls");return}else{b.$media.removeAttr("controls")}}b.createPlayer()};mejs.MediaElementPlayer.prototype={createPlayer:function(){var b=this,c=a.extend(true,{},b.options,{success:function(d,e){b.setupPlayer(d,e)},error:function(d){b.handleError(d)}});b.id="mep_"+mejs.mepIndex++;b.$media.before(a('<div id="'+b.id+'" class="mep-container"><div class="mep-mediaelement"></div><div class="mep-captions-layer"><span class="mep-captions-text"></span></div><div class="mep-poster"><img /></div><div class="mep-overlay"><div class="mep-overlay-button"></div></div><div class="mep-chapters"></div><div class="mep-controls">'+b.options.controlsTemplate+'</div><div class="mep-clear"></div></div>'));b.container=a("#"+this.id);b.container.find(".mep-captions-selector ul").append(a('<li><input type="radio" name="'+this.id+'_captions" id="'+this.id+'_captions_none" value="none" checked="checked" /><label for="'+this.id+'_captions_none">None</label></li>'));b.container.addClass(b.$media[0].className).find(".mep-mediaelement").append(b.$media);if(b.isVideo){b.width=(b.options.videoWidth>0)?b.options.videoWidth:(b.$media[0].getAttribute("width")!==null)?b.$media.attr("width"):b.options.defaultVideoWidth;b.height=(b.options.videoHeight>0)?b.options.videoHeight:(b.$media[0].getAttribute("height")!==null)?b.$media.attr("height"):b.options.defaultVideoHeight}else{b.width=b.options.audioWidth;b.height=b.options.audioHeight}b.buildPoster();b.buildOverlay();b.buildCaptionsDisplay();b.setPlayerSize(b.width,b.height);b.buildControls();c.pluginWidth=b.height;c.pluginHeight=b.width;mejs.MediaElement(b.$media[0],c)},setupPlayer:function(b,d){var c=this;c.mediaElement=b;c.domNode=d;if(c.isVideo){c.overlay.show()}c.buildControlBar();c.buildPlayPause();c.buildTimeRail();c.buildVolumeControls();c.buildCaptionsControls();c.buildFullscreen();c.mediaElement.addEventListener("click",function(f){if(c.mediaElement.paused){c.mediaElement.play()}},true);c.mediaElement.addEventListener("play",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("playing",function(f){c.poster.hide();c.overlay.hide();c.playpause.removeClass("mep-play").addClass("mep-pause")},true);c.mediaElement.addEventListener("pause",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("paused",function(f){if(c.isVideo){c.overlay.show()}c.playpause.removeClass("mep-pause").addClass("mep-play")},true);c.mediaElement.addEventListener("ended",function(f){c.mediaElement.setCurrentTime(0);c.mediaElement.pause();if(c.options.loop){c.mediaElement.play()}else{c.poster.show();c.overlay.show();c.controls.css("visibility","visible");c.playpause.removeClass("mep-pause").addClass("mep-play");c.setTimePosition()}},true);c.mediaElement.addEventListener("loadedmetadata",function(f){c.displayChapters();if(c.isVideo&&c.options.videoHeight<=0&&c.$media[0].getAttribute("height")===null&&!isNaN(f.target.videoHeight)){c.setPlayerSize(f.target.videoWidth,f.target.videoHeight);c.setRailSize();c.mediaElement.setVideoSize(f.target.videoWidth,f.target.videoHeight)}},true);setTimeout(function(){c.setRailSize()},50);if(c.options.success){c.options.success(c.mediaElement,c.domNode)}this.findTracks()},buildCaptionsDisplay:function(){var d=this,b="",c;d.captionsDisplay=d.container.find(".mep-captions-layer").hide();d.captionsText=d.container.find(".mep-captions-text");d.chapters=d.container.find(".mep-chapters");if(d.options.translationSelector){for(c in mejs.language.codes){b+='<option value="'+c+'">'+mejs.language.codes[c]+"</option>"}d.container.find(".mep-captions-selector ul").before(a('<select class="mep-captions-translations"><option value="">--Add Translation--</option>'+b+"</select>"));d.container.find(".mep-captions-translations").change(function(){var e=a(this);lang=e.val();if(lang!=""){d.tracks.push({srclang:lang,src:null,entries:[],isLoaded:false,isTranslation:true});if(!d.isLoadingTrack){d.trackToLoad--;d.addTrackButton(lang,true);d.options.startLanguage=lang;d.loadNextTrack()}}})}},buildCaptionsControls:function(){var c=this,d,b;c.captions.delegate("input[type=radio]","click",function(){d=this.value;if(d=="none"){c.selectedTrack=null}else{for(b=0;b<c.tracks.length;b++){if(c.tracks[b].srclang==d){c.selectedTrack=c.tracks[b];c.captionsDisplay.attr("lang",c.selectedTrack.srclang);c.displayCaptions();break}}}})},findTracks:function(){var c=this,b,d=c.$media.find("track");c.tracks=[];c.trackToLoad=-1;c.selectedTrack=null;c.isLoadingTrack=false;d.each(function(){c.tracks.push({srclang:a(this).attr("srclang").toLowerCase(),src:a(this).attr("src"),kind:a(this).attr("kind"),entries:[],isLoaded:false,isTranslation:false})});if(c.tracks.length>0&&c.options.translations.length>0){for(b=0;b<c.options.translations.length;b++){c.tracks.push({srclang:c.options.translations[b].toLowerCase(),src:null,kind:"subtitles",entries:[],isLoaded:false,isTranslation:true})}}for(b=0;b<c.tracks.length;b++){if(c.tracks[b].kind=="subtitles"){c.addTrackButton(c.tracks[b].srclang,c.tracks[b].isTranslation)}}if(c.tracks.length>0){c.loadNextTrack()}else{c.captions.remove();c.setRailSize()}},loadNextTrack:function(){var b=this;b.trackToLoad++;if(b.trackToLoad<b.tracks.length){b.isLoadingTrack=true;b.loadTrack(b.trackToLoad)}else{b.isLoadingTrack=false}},loadTrack:function(c){var d=this,b=d.tracks[c],e=function(){b.isLoaded=true;d.enableTrackButton(b.srclang);d.loadNextTrack()};if(b.isTranslation){mejs.SrtParser.translateSrt(d.tracks[0].entries,d.tracks[0].srclang,b.srclang,d.options.googleApiKey,function(f){b.entries=f;e()})}else{a.ajax({url:b.src,success:function(f){b.entries=mejs.SrtParser.parse(f);e();if(b.kind=="chapters"&&d.mediaElement.duration>0){d.buildChapters(b)}},error:function(){d.loadNextTrack()}})}},enableTrackButton:function(c){var b=this;b.captions.find("input[value="+c+"]").attr("disabled","").siblings("label").html(mejs.language.codes[c]||c);if(b.options.startLanguage==c){a("#"+b.id+"_captions_"+c).click()}b.adjustLanguageBox()},addTrackButton:function(e,d){var c=this,b=mejs.language.codes[e]||e;c.captions.find("ul").append(a('<li><input type="radio" name="'+c.id+'_captions" id="'+c.id+"_captions_"+e+'" value="'+e+'" disabled="disabled" /><label for="'+c.id+"_captions_"+e+'">'+b+((d)?" (translating)":" (loading)")+"</label></li>"));c.adjustLanguageBox();c.container.find(".mep-captions-translations option[value="+e+"]").remove()},adjustLanguageBox:function(){var b=this;b.captions.find(".mep-captions-selector").height(b.captions.find(".mep-captions-selector ul").outerHeight(true)+b.captions.find(".mep-captions-translations").outerHeight(true))},displayCaptions:function(){if(typeof this.tracks=="undefined"){return}var d=this,c,b=d.selectedTrack;if(b!=null&&b.isLoaded){for(c=0;c<b.entries.times.length;c++){if(d.mediaElement.currentTime>=b.entries.times[c].start&&d.mediaElement.currentTime<=b.entries.times[c].stop){d.captionsText.html(b.entries.text[c]);d.captionsDisplay.show();return}}d.captionsDisplay.hide()}else{d.captionsDisplay.hide()}},displayChapters:function(){var c=this,b;for(b=0;b<c.tracks.length;b++){if(c.tracks[b].kind=="chapters"){c.buildChapters(c.tracks[b]);break}}},buildChapters:function(f){var c=this,b,e,d,g;c.chapters.empty();for(b=0;b<f.entries.times.length;b++){e=f.entries.times[b].stop-f.entries.times[b].start;d=Math.floor(c.width*e/c.mediaElement.duration);g=Math.floor(c.width*f.entries.times[b].start/c.mediaElement.duration);if(g+d>c.width){d=c.width-g}c.chapters.append(a('<div class="mep-chapter" rel="'+f.entries.times[b].start+'" style="left: '+g.toString()+"px;width: "+d.toString()+'px;"><div class="mep-chapter-block'+((b==f.entries.times.length-1)?" mep-chapter-block-last":"")+'"><span class="ch-title">'+f.entries.text[b]+'</span><span class="ch-time">'+mejs.Utility.secondsToTimeCode(f.entries.times[b].start)+"&ndash;"+mejs.Utility.secondsToTimeCode(f.entries.times[b].stop)+"</span></div></div>"))}c.chapters.find("div.mep-chapter").click(function(){c.mediaElement.setCurrentTime(parseFloat(a(this).attr("rel")));if(c.mediaElement.paused){c.mediaElement.play()}})},buildPoster:function(){var b=this;b.poster=b.container.find(".mep-poster");b.posterImg=b.poster.find("img");b.posterUrl=b.$media.attr("poster");b.posterUrl=(b.posterUrl===null||b.posterUrl==undefined)?"":b.posterUrl;if(b.posterUrl!==""){b.posterImg.attr("src",b.posterUrl)}else{b.poster.hide()}},buildOverlay:function(){var b=this;b.overlay=b.container.find(".mep-overlay");b.overlay.bind("click",function(c){if(b.mediaElement.paused){b.mediaElement.play()}});b.overlay.hide()},buildControls:function(){var b=this;b.controls=b.container.find(".mep-controls");b.isControlsVisible=true;b.playpause=b.controls.find(".mep-playpause-button");b.fullscreen=b.controls.find(".mep-fullscreen-button");if(!b.isVideo){b.fullscreen.remove()}b.time=b.controls.find(".mep-time");b.currentTime=b.controls.find(".mep-currenttime").html("00:00");b.duration=b.controls.find(".mep-duration").html("00:00");b.captions=b.controls.find(".mep-captions-button");b.mute=b.controls.find(".mep-volume-button");b.volumeSlider=b.controls.find(".mep-volume-slider");b.volumeRail=b.controls.find(".mep-volume-rail");b.volumeHandle=b.controls.find(".mep-volume-handle");b.timeRail=b.controls.find(".mep-time-rail");b.timeCurrent=b.timeRail.find(".mep-time-current").width(0);b.timeLoaded=b.timeRail.find(".mep-time-loaded").width(0);b.timeTotal=b.timeRail.find(".mep-time-total");b.timeHandle=b.controls.find(".mep-time-handle");b.controls.show();b.setRailSize();b.controls.hide();if(!b.options.controls.playpause){b.playpause.remove()}if(!b.options.controls.timerail){b.timeRail.remove()}if(!b.options.controls.duration){b.time.remove()}if(!b.options.controls.volume){b.mute.remove()}if(!b.options.controls.fullscreen){b.fullscreen.remove()}},buildControlBar:function(){var b=this;b.controls.show();if(b.isVideo){b.container.bind("mouseenter",function(){b.controls.css("visibility","visible");b.controls.fadeIn(200);b.captionsDisplay.css("padding-bottom",b.controls.height()+5);b.setRailSize();b.isControlsVisible=true;b.chapters.css("visibility","visible");b.chapters.fadeIn(200)}).bind("mouseleave",function(){if(!b.mediaElement.paused){b.controls.fadeOut(200,function(){a(this).css("visibility","hidden");a(this).css("display","block");b.captionsDisplay.css("padding-bottom",10)});b.isControlsVisible=false;b.chapters.fadeOut(200,function(){a(this).css("visibility","hidden");a(this).css("display","block")})}})}},buildPlayPause:function(){var b=this;b.playpause.bind("click",function(){if(b.playpause.hasClass("mep-play")){b.mediaElement.play();b.playpause.removeClass("mep-play").addClass("mep-pause")}else{b.mediaElement.pause();b.playpause.removeClass("mep-pause").addClass("mep-play")}})},buildTimeRail:function(){var b=this;b.timeRail.delegate("span","click",function(h){var c=h.pageX,i=b.timeTotal.offset(),f=b.timeTotal.outerWidth(),d=((c-i.left)/f),g=d*b.mediaElement.duration;b.mediaElement.setCurrentTime(g)});b.mediaElement.addEventListener("timeupdate",function(c){b.displayCaptions();b.setTimePosition();b.setTimeLoaded(c.target)},true);b.mediaElement.addEventListener("progress",function(c){b.setTimeLoaded(c.target)},true)},setTimePosition:function(){var b=this,d,c;if(b.mediaElement.currentTime&&b.mediaElement.duration){b.currentTime.html(mejs.Utility.secondsToTimeCode(b.mediaElement.currentTime));if(b.mediaElement.duration){b.duration.html(mejs.Utility.secondsToTimeCode(b.mediaElement.duration))}d=b.timeTotal.width()*b.mediaElement.currentTime/b.mediaElement.duration;c=d-(b.timeHandle.width()/2);b.timeCurrent.width(d);b.timeHandle.css("left",c)}},setTimeLoaded:function(d){var b=this,c=null;if(d&&d.bytesTotal!=undefined&&d.bytesTotal>0&&d.bufferedBytes!=undefined){c=d.bufferedBytes/d.bytesTotal}else{if(d&&d.buffered&&d.buffered.length>0&&d.buffered.end&&d.duration){c=d.buffered.end(0)/d.duration}}if(c!==null){b.timeLoaded.width(b.timeTotal.width()*c)}},setRailSize:function(){var b=this,c=b.playpause.outerWidth(true)+b.time.outerWidth(true)+b.mute.outerWidth(true)+b.captions.outerWidth(true)+((b.isVideo)?b.fullscreen.outerWidth(true):0),d=b.controls.width()-c-(b.timeRail.outerWidth(true)-b.timeRail.outerWidth(false));b.timeRail.width(d);b.timeTotal.width(d-(b.timeTotal.outerWidth(true)-b.timeTotal.width()))},setPlayerSize:function(d,b){var c=this;c.width=parseInt(d,10);c.height=parseInt(b,10);c.container.width(c.width).height(c.height);c.captionsDisplay.width(c.width);c.overlay.width(c.width).height(c.height);c.posterImg.height(c.height).width(c.width)},handleError:function(c){var b=this;b.$media.hide();b.overlay.hide();b.controls.hide();b.poster.hide()},buildFullscreen:function(){var b=this;b.isFullScreen=false;b.normalHeight=0;b.normalWidth=0;b.fullscreen.bind("click",function(){b.setFullScreen(!b.isFullScreen)})},setFullScreen:function(b){var c=this;switch(c.mediaElement.pluginType){case"flash":c.mediaElement.setFullscreen(b);break;case"silverlight":c.mediaElement.setFullscreen(b);break;case"native":if(mejs.MediaFeatures.hasNativeFullScreen){if(b){c.mediaElement.webkitEnterFullScreen()}else{c.mediaElement.webkitExitFullScreen()}}else{if(b){c.normalHeight=c.$media.height();c.normalWidth=c.$media.width();c.container.addClass("mep-container-fullscreen").width("100%").height("100%").css("z-index",1000);c.$media.width("100%").height("100%");c.captionsDisplay.width("100%");c.overlay.width("100%").height("100%");c.posterImg.width("100%").height("auto");c.fullscreen.removeClass("mep-fullscreen").addClass("mep-unfullscreen");c.setRailSize();c.escB=function(d){c.escListener(d)};c.resB=function(d){c.resizeListener(d)};a(document).bind("keydown",c.escB);a(window).bind("resize",c.resB)}else{c.container.removeClass("mep-container-fullscreen").width(c.normalWidth).height(c.normalHeight).css("z-index",1);c.$media.width(c.normalWidth).height(c.normalHeight);c.posterImg.width(c.normalWidth).height(c.normalHeight);c.captionsDisplay.width(c.normalWidth);c.fullscreen.removeClass("mep-unfullscreen").addClass("mep-fullscreen");c.setRailSize();a(document).unbind("keydown",c.escB);a(window).unbind("resize",c.resB)}}}c.isFullScreen=b},escListener:function(b){if(b.keyCode==27){this.setFullScreen(false)}},resizeListener:function(b){this.setRailSize()},buildVolumeControls:function(){var b=this;b.vmmB=function(c){b.volumeMove(c)};b.vrmB=function(c){b.removeMouseMove(c)};b.volumeSlider.bind("mousedown",function(c){b.volumeMove(c);a(document).bind("mousemove",b.vmmB).bind("mouseup",b.vrmB)});b.mute.find("span").bind("click",function(){if(b.mediaElement.muted){b.mediaElement.setMuted(false);b.mute.removeClass("mep-unmute").addClass("mep-mute");b.positionVolumeHandle(1)}else{b.mediaElement.setMuted(true);b.mute.removeClass("mep-mute").addClass("mep-unmute");b.positionVolumeHandle(0)}});b.mediaElement.addEventListener("volumechange",function(c){b.positionVolumeHandle(c.target.volume)},true);b.mediaElement.setVolume(b.options.startVolume)},volumeMove:function(g){var c=this,b=c.volumeRail.height(),f=g.pageY-c.volumeRail.offset().top,d=(b-f)/b;if(f<0){f=0}else{if(f>b){f=b}}c.volumeHandle.css("top",f-(c.volumeHandle.height()/2));if(d==0){c.mediaElement.setMuted(true);c.mute.removeClass("mep-mute").addClass("mep-unmute")}else{c.mediaElement.setMuted(false);c.mute.removeClass("mep-unmute").addClass("mep-mute")}c.mediaElement.setVolume(d)},positionVolumeHandle:function(c){var b=this;b.volumeHandle.css("top",b.volumeRail.height()-(b.volumeRail.height()*c)-(b.volumeHandle.height()/2))},removeMouseMove:function(){var b=this;a(document).unbind("mousemove",b.vmmB).unbind("mouseup",b.vrmB)}};mejs.language={codes:{af:"Afrikaans",sq:"Albanian",ar:"Arabic",be:"Belarusian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese","zh-cn":"Chinese Simplified","zh-tw":"Chinese Traditional",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",tl:"Filipino",fi:"Finnish",fr:"French",gl:"Galician",de:"German",el:"Greek",ht:"Haitian Creole",iw:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese",ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",mt:"Maltese",no:"Norwegian",fa:"Persian",pl:"Polish",pt:"Portuguese",ro:"Romanian",ru:"Russian",sr:"Serbian",sk:"Slovak",sl:"Slovenian",es:"Spanish",sw:"Swahili",sv:"Swedish",tl:"Tagalog",th:"Thai",tr:"Turkish",uk:"Ukrainian",vi:"Vietnamese",cy:"Welsh",yi:"Yiddish"}};mejs.SrtParser={pattern_identifier:/^[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}(,[0-9]{3})?)(.*)$/,timecodeToSeconds:function(b){var c=b.split(":");return c[0]*60*60+c[1]*60+parseFloat(c[2].replace(",","."))},split2:function(c,b){return c.split(b)},parse:function(e){var f=0,d=this.split2(e,/\r?\n/),c={text:[],times:[]},b,g;for(;f<d.length;f++){if(this.pattern_identifier.exec(d[f])){f++;b=this.pattern_timecode.exec(d[f]);if(b&&f<d.length){f++;g=d[f];f++;while(d[f]!==""&&f<d.length){g=g+"\n"+d[f];f++}c.text.push(g);c.times.push({start:this.timecodeToSeconds(b[1]),stop:this.timecodeToSeconds(b[3]),settings:b[5]})}}}return c},translateSrt:function(d,j,f,g,h){var b={text:[],times:[]},c,e;this.translateText(d.text.join(" <a></a>"),j,f,g,function(i){c=i.split("<a></a>");for(e=0;e<d.text.length;e++){b.text[e]=c[e];b.times[e]={start:d.times[e].start,stop:d.times[e].stop,settings:d.times[e].settings}}h(b)})},translateText:function(j,f,d,c,i){var l,e=[],h,b=1000,k="",g=function(){if(e.length>0){h=e.shift();mejs.SrtParser.translateChunk(h,f,d,c,function(m){if(m!="undefined"){k+=m}g()})}else{i(k)}};while(j.length>0){if(j.length>b){l=j.lastIndexOf(".",b);e.push(j.substring(0,l));j=j.substring(l+1)}else{e.push(j);j=""}}g()},translateChunk:function(e,g,c,d,f){var b={q:e,langpair:g+"|"+c,v:"1.0"};if(d!==""&&d!==null){b.key=d}a.ajax({url:"https://ajax.googleapis.com/ajax/services/language/translate",data:b,type:"GET",dataType:"jsonp",success:function(h){f(h.responseData.translatedText)},error:function(h){f(null)}})}};if("x\n\ny".split(/\n/gi).length!=3){mejs.SrtParser.split2=function(f,d){var e=[],b="",c;for(c=0;c<f.length;c++){b+=f.substring(c,c+1);if(d.test(b)){e.push(b.replace(d,""));b=""}}e.push(b);return e}}jQuery.fn.mediaelementplayer=function(b){return this.each(function(){return new mejs.MediaElementPlayer(a(this),b)})};window.MediaElementPlayer=mejs.MediaElementPlayer})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.