­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ if (typeof jQuery != 'undefined') { mejs.$ = jQuery; } else if (typeof ender != 'undefined') { mejs.$ = ender; } (function ($) { mejs.MepDefaults = { poster: '', defaultVideoWidth: 480, defaultVideoHeight: 270, videoWidth: -1, videoHeight: -1, defaultAudioWidth: 400, defaultAudioHeight: 30, defaultSeekBackwardInterval: function(media) { return (media.duration * 0.05); }, defaultSeekForwardInterval: function(media) { return (media.duration * 0.05); }, audioWidth: -1, audioHeight: -1, startVolume: 0.8, loop: false, autoRewind: true, enableAutosize: true, alwaysShowHours: false, showTimecodeFrameCount: false, framesPerSecond: 25, autosizeProgress : true, alwaysShowControls: false, clickToPlayPause: true, iPadUseNativeControls: false, iPhoneUseNativeControls: false, AndroidUseNativeControls: false, features: ['playpause','current','progress','duration','tracks','volume','fullscreen'], isVideo: true, enableKeyboard: true, pauseOtherPlayers: true, keyActions: [ { keys: [ 32, 179 ], action: function(player, media) { if (media.paused || media.ended) { media.play(); } else { media.pause(); } } }, { keys: [38], action: function(player, media) { var newVolume = Math.min(media.volume + 0.1, 1); media.setVolume(newVolume); } }, { keys: [40], action: function(player, media) { var newVolume = Math.max(media.volume - 0.1, 0); media.setVolume(newVolume); } }, { keys: [ 37, 227 ], action: function(player, media) { if (!isNaN(media.duration) && media.duration > 0) { if (player.isVideo) { player.showControls(); player.startControlsTimer(); } var newTime = Math.max(media.currentTime - player.options.defaultSeekBackwardInterval(media), 0); media.setCurrentTime(newTime); } } }, { keys: [ 39, 228 ], action: function(player, media) { if (!isNaN(media.duration) && media.duration > 0) { if (player.isVideo) { player.showControls(); player.startControlsTimer(); } var newTime = Math.min(media.currentTime + player.options.defaultSeekForwardInterval(media), media.duration); media.setCurrentTime(newTime); } } }, { keys: [70], action: function(player, media) { if (typeof player.enterFullScreen != 'undefined') { if (player.isFullScreen) { player.exitFullScreen(); } else { player.enterFullScreen(); } } } } ] }; mejs.mepIndex = 0; mejs.players = []; mejs.MediaElementPlayer = function(node, o) { if ( !(this instanceof mejs.MediaElementPlayer) ) { return new mejs.MediaElementPlayer(node, o); } var t = this; t.$media = t.$node = $(node); t.node = t.media = t.$media[0]; if (typeof t.node.player != 'undefined') { return t.node.player; } else { t.node.player = t; } if (typeof o == 'undefined') { o = t.$node.data('mejsoptions'); } t.options = $.extend({},mejs.MepDefaults,o); mejs.players.push(t); t.init(); return t; }; mejs.MediaElementPlayer.prototype = { hasFocus: false, controlsAreVisible: true, init: function() { var t = this, mf = mejs.MediaFeatures, meOptions = $.extend(true, {}, t.options, { success: function(media, domNode) { t.meReady(media, domNode); }, error: function(e) { t.handleError(e);} }), tagName = t.media.tagName.toLowerCase(); t.isDynamic = (tagName !== 'audio' && tagName !== 'video'); if (t.isDynamic) { t.isVideo = t.options.isVideo; } else { t.isVideo = (tagName !== 'audio' && t.options.isVideo); } if ((mf.isiPad && t.options.iPadUseNativeControls) || (mf.isiPhone && t.options.iPhoneUseNativeControls)) { t.$media.attr('controls', 'controls'); if (mf.isiPad && t.media.getAttribute('autoplay') !== null) { t.media.load(); t.media.play(); } } else if (mf.isAndroid && t.AndroidUseNativeControls) { } else { t.$media.removeAttr('controls'); t.id = 'mep_' + mejs.mepIndex++; t.container = $('
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
' + '
') .addClass(t.$media[0].className) .insertBefore(t.$media); t.container.addClass( (mf.isAndroid ? 'mejs-android ' : '') + (mf.isiOS ? 'mejs-ios ' : '') + (mf.isiPad ? 'mejs-ipad ' : '') + (mf.isiPhone ? 'mejs-iphone ' : '') + (t.isVideo ? 'mejs-video ' : 'mejs-audio ') ); if (mf.isiOS) { var $newMedia = t.$media.clone(); t.container.find('.mejs-mediaelement').append($newMedia); t.$media.remove(); t.$node = t.$media = $newMedia; t.node = t.media = $newMedia[0] } else { t.container.find('.mejs-mediaelement').append(t.$media); } t.controls = t.container.find('.mejs-controls'); t.layers = t.container.find('.mejs-layers'); var tagType = (t.isVideo ? 'video' : 'audio'), capsTagName = tagType.substring(0,1).toUpperCase() + tagType.substring(1); if (t.options[tagType + 'Width'] > 0 || t.options[tagType + 'Width'].toString().indexOf('%') > -1) { t.width = t.options[tagType + 'Width']; } else if (t.media.style.width !== '' && t.media.style.width !== null) { t.width = t.media.style.width; } else if (t.media.getAttribute('width') !== null) { t.width = t.$media.attr('width'); } else { t.width = t.options['default' + capsTagName + 'Width']; } if (t.options[tagType + 'Height'] > 0 || t.options[tagType + 'Height'].toString().indexOf('%') > -1) { t.height = t.options[tagType + 'Height']; } else if (t.media.style.height !== '' && t.media.style.height !== null) { t.height = t.media.style.height; } else if (t.$media[0].getAttribute('height') !== null) { t.height = t.$media.attr('height'); } else { t.height = t.options['default' + capsTagName + 'Height']; } t.setPlayerSize(t.width, t.height); meOptions.pluginWidth = t.height; meOptions.pluginHeight = t.width; } mejs.MediaElement(t.$media[0], meOptions); t.container.trigger('controlsshown'); }, showControls: function(doAnimation) { var t = this; doAnimation = typeof doAnimation == 'undefined' || doAnimation; if (t.controlsAreVisible) return; if (doAnimation) { t.controls .css('visibility','visible') .stop(true, true).fadeIn(200, function() { t.controlsAreVisible = true; t.container.trigger('controlsshown'); }); t.container.find('.mejs-control') .css('visibility','visible') .stop(true, true).fadeIn(200, function() {t.controlsAreVisible = true;}); } else { t.controls .css('visibility','visible') .css('display','block'); t.container.find('.mejs-control') .css('visibility','visible') .css('display','block'); t.controlsAreVisible = true; t.container.trigger('controlsshown'); } t.setControlsSize(); }, hideControls: function(doAnimation) { var t = this; doAnimation = typeof doAnimation == 'undefined' || doAnimation; if (!t.controlsAreVisible) return; if (doAnimation) { t.controls.stop(true, true).fadeOut(200, function() { $(this) .css('visibility','hidden') .css('display','block'); t.controlsAreVisible = false; t.container.trigger('controlshidden'); }); t.container.find('.mejs-control').stop(true, true).fadeOut(200, function() { $(this) .css('visibility','hidden') .css('display','block'); }); } else { t.controls .css('visibility','hidden') .css('display','block'); t.container.find('.mejs-control') .css('visibility','hidden') .css('display','block'); t.controlsAreVisible = false; t.container.trigger('controlshidden'); } }, controlsTimer: null, startControlsTimer: function(timeout) { var t = this; timeout = typeof timeout != 'undefined' ? timeout : 1500; t.killControlsTimer('start'); t.controlsTimer = setTimeout(function() { t.hideControls(); t.killControlsTimer('hide'); }, timeout); }, killControlsTimer: function(src) { var t = this; if (t.controlsTimer !== null) { clearTimeout(t.controlsTimer); delete t.controlsTimer; t.controlsTimer = null; } }, controlsEnabled: true, disableControls: function() { var t= this; t.killControlsTimer(); t.hideControls(false); this.controlsEnabled = false; }, enableControls: function() { var t= this; t.showControls(false); t.controlsEnabled = true; }, meReady: function(media, domNode) { var t = this, mf = mejs.MediaFeatures, autoplayAttr = domNode.getAttribute('autoplay'), autoplay = !(typeof autoplayAttr == 'undefined' || autoplayAttr === null || autoplayAttr === 'false'), featureIndex, feature; if (t.created) return; else t.created = true; t.media = media; t.domNode = domNode; if (!(mf.isAndroid && t.options.AndroidUseNativeControls) && !(mf.isiPad && t.options.iPadUseNativeControls) && !(mf.isiPhone && t.options.iPhoneUseNativeControls)) { t.buildposter(t, t.controls, t.layers, t.media); t.buildkeyboard(t, t.controls, t.layers, t.media); t.buildoverlays(t, t.controls, t.layers, t.media); t.findTracks(); for (featureIndex in t.options.features) { feature = t.options.features[featureIndex]; if (t['build' + feature]) { try { t['build' + feature](t, t.controls, t.layers, t.media); } catch (e) { } } } t.container.trigger('controlsready'); t.setPlayerSize(t.width, t.height); t.setControlsSize(); if (t.isVideo) { if (mejs.MediaFeatures.hasTouch) { t.$media.bind('touchstart', function() { if (t.controlsAreVisible) { t.hideControls(false); } else { if (t.controlsEnabled) { t.showControls(false); } } }); } else { t.media.addEventListener('click', function() { if (t.options.clickToPlayPause) { if (t.media.paused) { t.media.play(); } else { t.media.pause(); } } }); t.container .bind('mouseenter mouseover', function () { if (t.controlsEnabled) { if (!t.options.alwaysShowControls) { t.killControlsTimer('enter'); t.showControls(); t.startControlsTimer(2500); } } }) .bind('mousemove', function() { if (t.controlsEnabled) { if (!t.controlsAreVisible) { t.showControls(); } if (!t.options.alwaysShowControls) { t.startControlsTimer(2500); } } }) .bind('mouseleave', function () { if (t.controlsEnabled) { if (!t.media.paused && !t.options.alwaysShowControls) { t.startControlsTimer(1000); } } }); } if (autoplay && !t.options.alwaysShowControls) { t.hideControls(); } if (t.options.enableAutosize) { t.media.addEventListener('loadedmetadata', function(e) { if (t.options.videoHeight <= 0 && t.domNode.getAttribute('height') === null && !isNaN(e.target.videoHeight)) { t.setPlayerSize(e.target.videoWidth, e.target.videoHeight); t.setControlsSize(); t.media.setVideoSize(e.target.videoWidth, e.target.videoHeight); } }, false); } } media.addEventListener('play', function() { for (var i=0, il=mejs.players.length; i 0 || t.$node.css('max-width') === '100%' || (t.$node[0].currentStyle && t.$node[0].currentStyle.maxWidth === '100%')) { var nativeWidth = t.isVideo ? ((t.media.videoWidth && t.media.videoWidth > 0) ? t.media.videoWidth : t.options.defaultVideoWidth) : t.options.defaultAudioWidth, nativeHeight = t.isVideo ? ((t.media.videoHeight && t.media.videoHeight > 0) ? t.media.videoHeight : t.options.defaultVideoHeight) : t.options.defaultAudioHeight, parentWidth = t.container.parent().closest(':visible').width(), newHeight = t.isVideo || !t.options.autosizeProgress ? parseInt(parentWidth * nativeHeight/nativeWidth, 10) : nativeHeight; if (t.container.parent()[0].tagName.toLowerCase() === 'body') { parentWidth = $(window).width(); newHeight = $(window).height(); } if ( newHeight != 0 && parentWidth != 0 ) { t.container .width(parentWidth) .height(newHeight); t.$media .width('100%') .height('100%'); t.container.find('object, embed, iframe') .width('100%') .height('100%'); if (t.isVideo) { if (t.media.setVideoSize) { t.media.setVideoSize(parentWidth, newHeight); } } t.layers.children('.mejs-layer') .width('100%') .height('100%'); } } else { t.container .width(t.width) .height(t.height); t.layers.children('.mejs-layer') .width(t.width) .height(t.height); } }, setControlsSize: function() { var t = this, usedWidth = 0, railWidth = 0, rail = t.controls.find('.mejs-time-rail'), total = t.controls.find('.mejs-time-total'), current = t.controls.find('.mejs-time-current'), loaded = t.controls.find('.mejs-time-loaded'), others = rail.siblings(); if (t.options && !t.options.autosizeProgress) { railWidth = parseInt(rail.css('width')); } if (railWidth === 0 || !railWidth) { others.each(function() { if ($(this).css('position') != 'absolute') { usedWidth += $(this).outerWidth(true); } }); railWidth = t.controls.width() - usedWidth - (rail.outerWidth(true) - rail.width()); } rail.width(railWidth); total.width(railWidth - (total.outerWidth(true) - total.width())); if (t.setProgressRail) t.setProgressRail(); if (t.setCurrentRail) t.setCurrentRail(); }, buildposter: function(player, controls, layers, media) { var t = this, poster = $('
' + '
') .appendTo(layers), posterUrl = player.$media.attr('poster'); if (player.options.poster !== '') { posterUrl = player.options.poster; } if (posterUrl !== '' && posterUrl != null) { t.setPoster(posterUrl); } else { poster.hide(); } media.addEventListener('play',function() { poster.hide(); }, false); }, setPoster: function(url) { var t = this, posterDiv = t.container.find('.mejs-poster'), posterImg = posterDiv.find('img'); if (posterImg.length == 0) { posterImg = $('').appendTo(posterDiv); } posterImg.attr('src', url); }, buildoverlays: function(player, controls, layers, media) { var t = this; if (!player.isVideo) return; var loading = $('
'+ '
'+ '
') .hide() .appendTo(layers), error = $('
'+ '
'+ '
') .hide() .appendTo(layers), bigPlay = $('
'+ '
'+ '
') .appendTo(layers) .click(function() { if (t.options.clickToPlayPause) { if (media.paused) { media.play(); } else { media.pause(); } } }); media.addEventListener('play',function() { bigPlay.hide(); loading.hide(); controls.find('.mejs-time-buffering').hide(); error.hide(); }, false); media.addEventListener('playing', function() { bigPlay.hide(); loading.hide(); controls.find('.mejs-time-buffering').hide(); error.hide(); }, false); media.addEventListener('seeking', function() { loading.show(); controls.find('.mejs-time-buffering').show(); }, false); media.addEventListener('seeked', function() { loading.hide(); controls.find('.mejs-time-buffering').hide(); }, false); media.addEventListener('pause',function() { if (!mejs.MediaFeatures.isiPhone) { bigPlay.show(); } }, false); media.addEventListener('waiting', function() { loading.show(); controls.find('.mejs-time-buffering').show(); }, false); media.addEventListener('loadeddata',function() { loading.show(); controls.find('.mejs-time-buffering').show(); }, false); media.addEventListener('canplay',function() { loading.hide(); controls.find('.mejs-time-buffering').hide(); }, false); media.addEventListener('error',function() { loading.hide(); controls.find('.mejs-time-buffering').hide(); error.show(); error.find('mejs-overlay-error').html("Error loading this resource"); }, false); }, buildkeyboard: function(player, controls, layers, media) { var t = this; $(document).keydown(function(e) { if (player.hasFocus && player.options.enableKeyboard) { for (var i=0, il=player.options.keyActions.length; i' + '' + '') .appendTo(controls) .click(function(e) { e.preventDefault(); if (media.paused) { media.play(); } else { media.pause(); } return false; }); media.addEventListener('play',function() { play.removeClass('mejs-play').addClass('mejs-pause'); }, false); media.addEventListener('playing',function() { play.removeClass('mejs-play').addClass('mejs-pause'); }, false); media.addEventListener('pause',function() { play.removeClass('mejs-pause').addClass('mejs-play'); }, false); media.addEventListener('paused',function() { play.removeClass('mejs-pause').addClass('mejs-play'); }, false); } }); })(mejs.$); (function($) { $.extend(mejs.MepDefaults, { stopText: 'Stop' }); $.extend(MediaElementPlayer.prototype, { buildstop: function(player, controls, layers, media) { var t = this, stop = $('
' + '' + '
') .appendTo(controls) .click(function() { if (!media.paused) { media.pause(); } if (media.currentTime > 0) { media.setCurrentTime(0); media.pause(); controls.find('.mejs-time-current').width('0px'); controls.find('.mejs-time-handle').css('left', '0px'); controls.find('.mejs-time-float-current').html( mejs.Utility.secondsToTimeCode(0) ); controls.find('.mejs-currenttime').html( mejs.Utility.secondsToTimeCode(0) ); layers.find('.mejs-poster').show(); } }); } }); })(mejs.$); (function($) { $.extend(MediaElementPlayer.prototype, { buildprogress: function(player, controls, layers, media) { $('
'+ ''+ ''+ ''+ ''+ ''+ '' + '00:00' + '' + ''+ ''+ '
') .appendTo(controls); controls.find('.mejs-time-buffering').hide(); var t = this, total = controls.find('.mejs-time-total'), loaded = controls.find('.mejs-time-loaded'), current = controls.find('.mejs-time-current'), handle = controls.find('.mejs-time-handle'), timefloat = controls.find('.mejs-time-float'), timefloatcurrent = controls.find('.mejs-time-float-current'), handleMouseMove = function (e) { var x = e.pageX, offset = total.offset(), width = total.outerWidth(true), percentage = 0, newTime = 0, pos = 0; if (media.duration) { if (x < offset.left) { x = offset.left; } else if (x > width + offset.left) { x = width + offset.left; } pos = x - offset.left; percentage = (pos / width); newTime = (percentage <= 0.02) ? 0 : percentage * media.duration; if (mouseIsDown && newTime !== media.currentTime) { media.setCurrentTime(newTime); } if (!mejs.MediaFeatures.hasTouch) { timefloat.css('left', pos); timefloatcurrent.html( mejs.Utility.secondsToTimeCode(newTime) ); timefloat.show(); } } }, mouseIsDown = false, mouseIsOver = false; total .bind('mousedown', function (e) { if (e.which === 1) { mouseIsDown = true; handleMouseMove(e); $(document) .bind('mousemove.dur', function(e) { handleMouseMove(e); }) .bind('mouseup.dur', function (e) { mouseIsDown = false; timefloat.hide(); $(document).unbind('.dur'); }); return false; } }) .bind('mouseenter', function(e) { mouseIsOver = true; $(document).bind('mousemove.dur', function(e) { handleMouseMove(e); }); if (!mejs.MediaFeatures.hasTouch) { timefloat.show(); } }) .bind('mouseleave',function(e) { mouseIsOver = false; if (!mouseIsDown) { $(document).unbind('.dur'); timefloat.hide(); } }); media.addEventListener('progress', function (e) { player.setProgressRail(e); player.setCurrentRail(e); }, false); media.addEventListener('timeupdate', function(e) { player.setProgressRail(e); player.setCurrentRail(e); }, false); t.loaded = loaded; t.total = total; t.current = current; t.handle = handle; }, setProgressRail: function(e) { var t = this, target = (e != undefined) ? e.target : t.media, percent = null; if (target && target.buffered && target.buffered.length > 0 && target.buffered.end && target.duration) { percent = target.buffered.end(0) / target.duration; } else if (target && target.bytesTotal != undefined && target.bytesTotal > 0 && target.bufferedBytes != undefined) { percent = target.bufferedBytes / target.bytesTotal; } else if (e && e.lengthComputable && e.total != 0) { percent = e.loaded/e.total; } if (percent !== null) { percent = Math.min(1, Math.max(0, percent)); if (t.loaded && t.total) { t.loaded.width(t.total.width() * percent); } } }, setCurrentRail: function() { var t = this; if (t.media.currentTime != undefined && t.media.duration) { if (t.total && t.handle) { var newWidth = t.total.width() * t.media.currentTime / t.media.duration, handlePos = newWidth - (t.handle.outerWidth(true) / 2); t.current.width(newWidth); t.handle.css('left', handlePos); } } } }); })(mejs.$); (function($) { $.extend(mejs.MepDefaults, { duration: -1, timeAndDurationSeparator: ' | ' }); $.extend(MediaElementPlayer.prototype, { buildcurrent: function(player, controls, layers, media) { var t = this; $('
'+ '' + (player.options.alwaysShowHours ? '00:' : '') + (player.options.showTimecodeFrameCount? '00:00:00':'00:00')+ ''+ '
') .appendTo(controls); t.currenttime = t.controls.find('.mejs-currenttime'); media.addEventListener('timeupdate',function() { player.updateCurrent(); }, false); }, buildduration: function(player, controls, layers, media) { var t = this; if (controls.children().last().find('.mejs-currenttime').length > 0) { $(t.options.timeAndDurationSeparator + '' + (t.options.duration > 0 ? mejs.Utility.secondsToTimeCode(t.options.duration, t.options.alwaysShowHours || t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond || 25) : ((player.options.alwaysShowHours ? '00:' : '') + (player.options.showTimecodeFrameCount? '00:00:00':'00:00')) ) + '') .appendTo(controls.find('.mejs-time')); } else { controls.find('.mejs-currenttime').parent().addClass('mejs-currenttime-container'); $('
'+ '' + (t.options.duration > 0 ? mejs.Utility.secondsToTimeCode(t.options.duration, t.options.alwaysShowHours || t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond || 25) : ((player.options.alwaysShowHours ? '00:' : '') + (player.options.showTimecodeFrameCount? '00:00:00':'00:00')) ) + '' + '
') .appendTo(controls); } t.durationD = t.controls.find('.mejs-duration'); media.addEventListener('timeupdate',function() { player.updateDuration(); }, false); }, updateCurrent: function() { var t = this; if (t.currenttime) { t.currenttime.html(mejs.Utility.secondsToTimeCode(t.media.currentTime, t.options.alwaysShowHours || t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond || 25)); } }, updateDuration: function() { var t = this; t.container.toggleClass("mejs-long-video", t.media.duration > 3600); if (t.media.duration && t.durationD) { t.durationD.html(mejs.Utility.secondsToTimeCode(t.media.duration, t.options.alwaysShowHours, t.options.showTimecodeFrameCount, t.options.framesPerSecond || 25)); } } }); })(mejs.$); (function($) { $.extend(mejs.MepDefaults, { muteText: 'Mute Toggle', hideVolumeOnTouchDevices: true, audioVolume: 'horizontal', videoVolume: 'vertical' }); $.extend(MediaElementPlayer.prototype, { buildvolume: function(player, controls, layers, media) { if (mejs.MediaFeatures.hasTouch && this.options.hideVolumeOnTouchDevices) return; var t = this, mode = (t.isVideo) ? t.options.videoVolume : t.options.audioVolume, mute = (mode == 'horizontal') ? $('
'+ ''+ '
' + '
'+ '
'+ '
'+ '
'+ '
' ) .appendTo(controls) : $('
'+ ''+ '
'+ '
'+ '
'+ '
'+ '
'+ '
') .appendTo(controls), volumeSlider = t.container.find('.mejs-volume-slider, .mejs-horizontal-volume-slider'), volumeTotal = t.container.find('.mejs-volume-total, .mejs-horizontal-volume-total'), volumeCurrent = t.container.find('.mejs-volume-current, .mejs-horizontal-volume-current'), volumeHandle = t.container.find('.mejs-volume-handle, .mejs-horizontal-volume-handle'), positionVolumeHandle = function(volume, secondTry) { if (!volumeSlider.is(':visible') && typeof secondTry == 'undefined') { volumeSlider.show(); positionVolumeHandle(volume, true); volumeSlider.hide() return; } volume = Math.max(0,volume); volume = Math.min(volume,1); if (volume == 0) { mute.removeClass('mejs-mute').addClass('mejs-unmute'); } else { mute.removeClass('mejs-unmute').addClass('mejs-mute'); } if (mode == 'vertical') { var totalHeight = volumeTotal.height(), totalPosition = volumeTotal.position(), newTop = totalHeight - (totalHeight * volume); volumeHandle.css('top', Math.round(totalPosition.top + newTop - (volumeHandle.height() / 2))); volumeCurrent.height(totalHeight - newTop ); volumeCurrent.css('top', totalPosition.top + newTop); } else { var totalWidth = volumeTotal.width(), totalPosition = volumeTotal.position(), newLeft = totalWidth * volume; volumeHandle.css('left', Math.round(totalPosition.left + newLeft - (volumeHandle.width() / 2))); volumeCurrent.width( Math.round(newLeft) ); } }, handleVolumeMove = function(e) { var volume = null, totalOffset = volumeTotal.offset(); if (mode == 'vertical') { var railHeight = volumeTotal.height(), totalTop = parseInt(volumeTotal.css('top').replace(/px/,''),10), newY = e.pageY - totalOffset.top; volume = (railHeight - newY) / railHeight; if (totalOffset.top == 0 || totalOffset.left == 0) return; } else { var railWidth = volumeTotal.width(), newX = e.pageX - totalOffset.left; volume = newX / railWidth; } volume = Math.max(0,volume); volume = Math.min(volume,1); positionVolumeHandle(volume); if (volume == 0) { media.setMuted(true); } else { media.setMuted(false); } media.setVolume(volume); }, mouseIsDown = false, mouseIsOver = false; mute .hover(function() { volumeSlider.show(); mouseIsOver = true; }, function() { mouseIsOver = false; if (!mouseIsDown && mode == 'vertical') { volumeSlider.hide(); } }); volumeSlider .bind('mouseover', function() { mouseIsOver = true; }) .bind('mousedown', function (e) { handleVolumeMove(e); $(document) .bind('mousemove.vol', function(e) { handleVolumeMove(e); }) .bind('mouseup.vol', function () { mouseIsDown = false; $(document).unbind('.vol'); if (!mouseIsOver && mode == 'vertical') { volumeSlider.hide(); } }); mouseIsDown = true; return false; }); mute.find('button').click(function() { media.setMuted( !media.muted ); }); media.addEventListener('volumechange', function(e) { if (!mouseIsDown) { if (media.muted) { positionVolumeHandle(0); mute.removeClass('mejs-mute').addClass('mejs-unmute'); } else { positionVolumeHandle(media.volume); mute.removeClass('mejs-unmute').addClass('mejs-mute'); } } }, false); if (t.container.is(':visible')) { positionVolumeHandle(player.options.startVolume); if (media.pluginType === 'native') { media.setVolume(player.options.startVolume); } } } }); })(mejs.$); (function($) { $.extend(mejs.MepDefaults, { usePluginFullScreen: true, newWindowCallback: function() { return '';}, fullscreenText: mejs.i18n.t('Fullscreen') }); $.extend(MediaElementPlayer.prototype, { isFullScreen: false, isNativeFullScreen: false, docStyleOverflow: null, isInIframe: false, buildfullscreen: function(player, controls, layers, media) { if (!player.isVideo) return; player.isInIframe = (window.location != window.parent.location); if (mejs.MediaFeatures.hasTrueNativeFullScreen) { var target = null; if (mejs.MediaFeatures.hasMozNativeFullScreen) { target = $(document); } else { target = player.container; } target.bind(mejs.MediaFeatures.fullScreenEventName, function(e) { if (mejs.MediaFeatures.isFullScreen()) { player.isNativeFullScreen = true; player.setControlsSize(); } else { player.isNativeFullScreen = false; player.exitFullScreen(); } }); } var t = this, normalHeight = 0, normalWidth = 0, container = player.container, fullscreenBtn = $('
' + '' + '
') .appendTo(controls); if (t.media.pluginType === 'native' || (!t.options.usePluginFullScreen && !mejs.MediaFeatures.isFirefox)) { fullscreenBtn.click(function() { var isFullScreen = (mejs.MediaFeatures.hasTrueNativeFullScreen && mejs.MediaFeatures.isFullScreen()) || player.isFullScreen; if (isFullScreen) { player.exitFullScreen(); } else { player.enterFullScreen(); } }); } else { var hideTimeout = null, supportsPointerEvents = (function() { var element = document.createElement('x'), documentElement = document.documentElement, getComputedStyle = window.getComputedStyle, supports; if(!('pointerEvents' in element.style)){ return false; } element.style.pointerEvents = 'auto'; element.style.pointerEvents = 'x'; documentElement.appendChild(element); supports = getComputedStyle && getComputedStyle(element, '').pointerEvents === 'auto'; documentElement.removeChild(element); return !!supports; })(); if (supportsPointerEvents && !mejs.MediaFeatures.isOpera) { var fullscreenIsDisabled = false, restoreControls = function() { if (fullscreenIsDisabled) { videoHoverDiv.hide(); controlsLeftHoverDiv.hide(); controlsRightHoverDiv.hide(); fullscreenBtn.css('pointer-events', ''); t.controls.css('pointer-events', ''); fullscreenIsDisabled = false; } }, videoHoverDiv = $('
').appendTo(t.container).mouseover(restoreControls), controlsLeftHoverDiv = $('
').appendTo(t.container).mouseover(restoreControls), controlsRightHoverDiv = $('
').appendTo(t.container).mouseover(restoreControls), positionHoverDivs = function() { var style = {position: 'absolute', top: 0, left: 0}; videoHoverDiv.css(style); controlsLeftHoverDiv.css(style); controlsRightHoverDiv.css(style); videoHoverDiv .width( t.container.width() ) .height( t.container.height() - t.controls.height() ); var fullScreenBtnOffset = fullscreenBtn.offset().left - t.container.offset().left; fullScreenBtnWidth = fullscreenBtn.outerWidth(true); controlsLeftHoverDiv .width( fullScreenBtnOffset ) .height( t.controls.height() ) .css({top: t.container.height() - t.controls.height()}); controlsRightHoverDiv .width( t.container.width() - fullScreenBtnOffset - fullScreenBtnWidth ) .height( t.controls.height() ) .css({top: t.container.height() - t.controls.height(), left: fullScreenBtnOffset + fullScreenBtnWidth}); }; $(document).resize(function() { positionHoverDivs(); }); fullscreenBtn .mouseover(function() { if (!t.isFullScreen) { var buttonPos = fullscreenBtn.offset(), containerPos = player.container.offset(); media.positionFullscreenButton(buttonPos.left - containerPos.left, buttonPos.top - containerPos.top, false); fullscreenBtn.css('pointer-events', 'none'); t.controls.css('pointer-events', 'none'); videoHoverDiv.show(); controlsRightHoverDiv.show(); controlsLeftHoverDiv.show(); positionHoverDivs(); fullscreenIsDisabled = true; } }); media.addEventListener('fullscreenchange', function(e) { restoreControls(); }); } else { fullscreenBtn .mouseover(function() { if (hideTimeout !== null) { clearTimeout(hideTimeout); delete hideTimeout; } var buttonPos = fullscreenBtn.offset(), containerPos = player.container.offset(); media.positionFullscreenButton(buttonPos.left - containerPos.left, buttonPos.top - containerPos.top, true); }) .mouseout(function() { if (hideTimeout !== null) { clearTimeout(hideTimeout); delete hideTimeout; } hideTimeout = setTimeout(function() { media.hideFullscreenButton(); }, 1500); }); } } player.fullscreenBtn = fullscreenBtn; $(document).bind('keydown',function (e) { if (((mejs.MediaFeatures.hasTrueNativeFullScreen && mejs.MediaFeatures.isFullScreen()) || t.isFullScreen) && e.keyCode == 27) { player.exitFullScreen(); } }); }, enterFullScreen: function() { var t = this; if (t.media.pluginType !== 'native' && (mejs.MediaFeatures.isFirefox || t.options.usePluginFullScreen)) { return; } docStyleOverflow = document.documentElement.style.overflow; document.documentElement.style.overflow = 'hidden'; normalHeight = t.container.height(); normalWidth = t.container.width(); if (t.media.pluginType === 'native') { if (mejs.MediaFeatures.hasTrueNativeFullScreen) { mejs.MediaFeatures.requestFullScreen(t.container[0]); if (t.isInIframe) { setTimeout(function checkFullscreen() { if (t.isNativeFullScreen) { if ($(window).width() !== screen.width) { t.exitFullScreen(); } else { setTimeout(checkFullscreen, 500); } } }, 500); } } else if (mejs.MediaFeatures.hasSemiNativeFullScreen) { t.media.webkitEnterFullscreen(); return; } } if (t.isInIframe) { var url = t.options.newWindowCallback(this); if (url !== '') { if (!mejs.MediaFeatures.hasTrueNativeFullScreen) { t.pause(); window.open(url, t.id, 'top=0,left=0,width=' + screen.availWidth + ',height=' + screen.availHeight + ',resizable=yes,scrollbars=no,status=no,toolbar=no'); return; } else { setTimeout(function() { if (!t.isNativeFullScreen) { t.pause(); window.open(url, t.id, 'top=0,left=0,width=' + screen.availWidth + ',height=' + screen.availHeight + ',resizable=yes,scrollbars=no,status=no,toolbar=no'); } }, 250); } } } t.container .addClass('mejs-container-fullscreen') .width('100%') .height('100%'); setTimeout(function() { t.container.css({width: '100%', height: '100%'}); t.setControlsSize(); }, 500); if (t.pluginType === 'native') { t.$media .width('100%') .height('100%'); } else { t.container.find('object, embed, iframe') .width('100%') .height('100%'); t.media.setVideoSize($(window).width(),$(window).height()); } t.layers.children('div') .width('100%') .height('100%'); if (t.fullscreenBtn) { t.fullscreenBtn .removeClass('mejs-fullscreen') .addClass('mejs-unfullscreen'); } t.setControlsSize(); t.isFullScreen = true; }, exitFullScreen: function() { var t = this; if (t.media.pluginType !== 'native' && mejs.MediaFeatures.isFirefox) { t.media.setFullscreen(false); return; } if (mejs.MediaFeatures.hasTrueNativeFullScreen && (mejs.MediaFeatures.isFullScreen() || t.isFullScreen)) { mejs.MediaFeatures.cancelFullScreen(); } document.documentElement.style.overflow = docStyleOverflow; t.container .removeClass('mejs-container-fullscreen') .width(normalWidth) .height(normalHeight); if (t.pluginType === 'native') { t.$media .width(normalWidth) .height(normalHeight); } else { t.container.find('object embed') .width(normalWidth) .height(normalHeight); t.media.setVideoSize(normalWidth, normalHeight); } t.layers.children('div') .width(normalWidth) .height(normalHeight); t.fullscreenBtn .removeClass('mejs-unfullscreen') .addClass('mejs-fullscreen'); t.setControlsSize(); t.isFullScreen = false; } }); })(mejs.$); (function($) { $.extend(mejs.MepDefaults, { startLanguage: '', tracksText: 'Captions/Subtitles' }); $.extend(MediaElementPlayer.prototype, { hasChapters: false, buildtracks: function(player, controls, layers, media) { if (!player.isVideo) return; if (player.tracks.length == 0) return; var t= this, i, options = ''; player.chapters = $('
') .prependTo(layers).hide(); player.captions = $('
') .prependTo(layers).hide(); player.captionsText = player.captions.find('.mejs-captions-text'); player.captionsButton = $('
'+ ''+ '
'+ '
    '+ '
  • '+ '' + ''+ '
  • ' + '
'+ '
'+ '
') .appendTo(controls) .hover(function() { $(this).find('.mejs-captions-selector').css('visibility','visible'); }, function() { $(this).find('.mejs-captions-selector').css('visibility','hidden'); }) .delegate('input[type=radio]','click',function() { lang = this.value; if (lang == 'none') { player.selectedTrack = null; } else { for (i=0; i 0) { t.displayChapters(track); } }, false); } }, error: function() { t.loadNextTrack(); } }); }, enableTrackButton: function(lang, label) { var t = this; if (label === '') { label = mejs.language.codes[lang] || lang; } t.captionsButton .find('input[value=' + lang + ']') .prop('disabled',false) .siblings('label') .html( label ); if (t.options.startLanguage == lang) { $('#' + t.id + '_captions_' + lang).click(); } t.adjustLanguageBox(); }, addTrackButton: function(lang, label) { var t = this; if (label === '') { label = mejs.language.codes[lang] || lang; } t.captionsButton.find('ul').append( $('
  • '+ '' + ''+ '
  • ') ); t.adjustLanguageBox(); t.container.find('.mejs-captions-translations option[value=' + lang + ']').remove(); }, adjustLanguageBox:function() { var t = this; t.captionsButton.find('.mejs-captions-selector').height( t.captionsButton.find('.mejs-captions-selector ul').outerHeight(true) + t.captionsButton.find('.mejs-captions-translations').outerHeight(true) ); }, displayCaptions: function() { if (typeof this.tracks == 'undefined') return; var t = this, i, track = t.selectedTrack; if (track != null && track.isLoaded) { for (i=0; i= track.entries.times[i].start && t.media.currentTime <= track.entries.times[i].stop){ t.captionsText.html(track.entries.text[i]); t.captions.show().height(0); return; } } t.captions.hide(); } else { t.captions.hide(); } }, displayChapters: function() { var t = this, i; for (i=0; i 100 || i == chapters.entries.times.length-1 && percent + usedPercent < 100) { percent = 100 - usedPercent; } t.chapters.append( $( '
    ' + '
    ' + '' + chapters.entries.text[i] + '' + '' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].start) + '–' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].stop) + '' + '
    ' + '
    ')); usedPercent += percent; } t.chapters.find('div.mejs-chapter').click(function() { t.media.setCurrentTime( parseFloat( $(this).attr('rel') ) ); if (t.media.paused) { t.media.play(); } }); t.chapters.show(); } }); 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.TrackFormatParser = { webvvt: { pattern_identifier: /^([a-zA-z]+-)?[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})?)(.*)$/, parse: function(trackText) { var i = 0, lines = mejs.TrackFormatParser.split2(trackText, /\r?\n/), entries = {text:[], times:[]}, timecode, text; for(; i$1"); entries.text.push(text); entries.times.push( { start: (mejs.Utility.convertSMPTEtoSeconds(timecode[1]) == 0) ? 0.200 : mejs.Utility.convertSMPTEtoSeconds(timecode[1]), stop: mejs.Utility.convertSMPTEtoSeconds(timecode[3]), settings: timecode[5] }); } } } return entries; } }, dfxp: { parse: function(trackText) { trackText = $(trackText).filter("tt"); var i = 0, container = trackText.children("div").eq(0), lines = container.find("p"), styleNode = trackText.find("#" + container.attr("style")), styles, begin, end, text, entries = {text:[], times:[]}; if (styleNode.length) { var attributes = styleNode.removeAttr("id").get(0).attributes; if (attributes.length) { styles = {}; for (i = 0; i < attributes.length; i++) { styles[attributes[i].name.split(":")[1]] = attributes[i].value; } } } for(i = 0; i$1"); entries.text.push(text); if (entries.times.start == 0) entries.times.start = 2; } return entries; } }, split2: function (text, regex) { return text.split(regex); } }; if ('x\n\ny'.split(/\n/gi).length != 3) { mejs.TrackFormatParser.split2 = function(text, regex) { var parts = [], chunk = '', i; for (i=0; i
    ') .appendTo($('body')) .hide(); player.container.bind('contextmenu', function(e) { if (player.isContextMenuEnabled) { e.preventDefault(); player.renderContextMenu(e.clientX-1, e.clientY-1); return false; } }); player.container.bind('click', function() { player.contextMenu.hide(); }); player.contextMenu.bind('mouseleave', function() { player.startContextMenuTimer(); }); }, isContextMenuEnabled: true, enableContextMenu: function() { this.isContextMenuEnabled = true; }, disableContextMenu: function() { this.isContextMenuEnabled = false; }, contextMenuTimeout: null, startContextMenuTimer: function() { var t = this; t.killContextMenuTimer(); t.contextMenuTimer = setTimeout(function() { t.hideContextMenu(); t.killContextMenuTimer(); }, 750); }, killContextMenuTimer: function() { var timer = this.contextMenuTimer; if (timer != null) { clearTimeout(timer); delete timer; timer = null; } }, hideContextMenu: function() { this.contextMenu.hide(); }, renderContextMenu: function(x,y) { var t = this, html = '', items = t.options.contextMenuItems; for (var i=0, il=items.length; i' + rendered + '
    '; } } } t.contextMenu .empty() .append($(html)) .css({top:y, left:x}) .show(); t.contextMenu.find('.mejs-contextmenu-item').each(function() { var $dom = $(this), itemIndex = parseInt( $dom.data('itemindex'), 10 ), item = t.options.contextMenuItems[itemIndex]; if (typeof item.show != 'undefined') item.show( $dom , t); $dom.click(function() { if (typeof item.click != 'undefined') item.click(t); t.contextMenu.hide(); }); }); setTimeout(function() { t.killControlsTimer('rev3'); }, 100); } }); })(mejs.$); (function($) { $.extend(mejs.MepDefaults, { postrollCloseText: mejs.i18n.t('Close') }); $.extend(MediaElementPlayer.prototype, { buildpostroll: function(player, controls, layers, media) { var t = this, postrollLink = t.container.find('link[rel="postroll"]').attr('href'); if (typeof postrollLink !== 'undefined') { player.postroll = $('').prependTo(layers).hide(); t.media.addEventListener('ended', function (e) { $.ajax({ dataType: 'html', url: postrollLink, success: function (data, textStatus) { layers.find('.mejs-postroll-layer-content').html(data); } }); player.postroll.show(); }, false); } } }); })(mejs.$);