diff --git a/src/js/me-mediaelements.js b/src/js/me-mediaelements.js index 6dde1a6d3..5aab607bc 100644 --- a/src/js/me-mediaelements.js +++ b/src/js/me-mediaelements.js @@ -322,5 +322,6 @@ mejs.PluginMediaElement.prototype = { remove: function() { mejs.Utility.removeSwf(this.pluginElement.id); + mejs.MediaPluginBridge.unregisterPluginElement(this.pluginElement.id); } }; diff --git a/src/js/me-namespace.js b/src/js/me-namespace.js index d4e6a9e44..d62cab8d9 100644 --- a/src/js/me-namespace.js +++ b/src/js/me-namespace.js @@ -17,9 +17,9 @@ mejs.plugins = { //,{version: [12,0], types: ['video/webm']} // for future reference (hopefully!) ], youtube: [ - {version: null, types: ['video/youtube', 'video/x-youtube']} + {version: null, types: ['video/youtube', 'video/x-youtube', 'audio/youtube', 'audio/x-youtube']} ], vimeo: [ {version: null, types: ['video/vimeo', 'video/x-vimeo']} ] -}; \ No newline at end of file +}; diff --git a/src/js/me-shim.js b/src/js/me-shim.js index 13af7bdee..3089e2026 100644 --- a/src/js/me-shim.js +++ b/src/js/me-shim.js @@ -9,6 +9,11 @@ mejs.MediaPluginBridge = { this.htmlMediaElements[id] = htmlMediaElement; }, + unregisterPluginElement: function (id) { + delete this.pluginMediaElements[id]; + delete this.htmlMediaElements[id]; + }, + // when Flash/Silverlight is ready, it calls out to this method initPlugin: function (id) { @@ -504,7 +509,7 @@ mejs.HtmlMediaElementShim = { switch (playback.method) { case 'silverlight': container.innerHTML = -'' + +'' + '' + '' + '' + @@ -521,7 +526,7 @@ mejs.HtmlMediaElementShim = { container.appendChild(specialIEContainer); specialIEContainer.outerHTML = '' + +'id="' + pluginid + '" width="' + width + '" height="' + height + '" class="mejs-shim">' + '' + '' + '' + @@ -546,7 +551,8 @@ mejs.HtmlMediaElementShim = { 'src="' + options.pluginPath + options.flashName + '" ' + 'flashvars="' + initVars.join('&') + '" ' + 'width="' + width + '" ' + -'height="' + height + '">'; +'height="' + height + '" ' + +'class="mejs-shim">'; } break; @@ -579,16 +585,16 @@ mejs.HtmlMediaElementShim = { pluginMediaElement.vimeoid = playback.url.substr(playback.url.lastIndexOf('/')+1); - container.innerHTML =''; + container.innerHTML =''; /* container.innerHTML = - '' + + '' + '' + '' + '' + '' + - '' + + '' + ''; */ @@ -772,7 +778,7 @@ mejs.YouTubeApi = { /* settings.container.innerHTML = '' + + 'width="' + settings.width + '" height="' + settings.height + '" style="visibility: visible; " class="mejs-shim">' + '' + '' + ''; @@ -786,7 +792,7 @@ mejs.YouTubeApi = { specialIEContainer = document.createElement('div'); settings.container.appendChild(specialIEContainer); specialIEContainer.outerHTML = '' + +'id="' + settings.pluginId + '" width="' + settings.width + '" height="' + settings.height + '" class="mejs-shim">' + '' + '' + '' + @@ -795,7 +801,7 @@ mejs.YouTubeApi = { } else { settings.container.innerHTML = '' + + 'width="' + settings.width + '" height="' + settings.height + '" style="visibility: visible; " class="mejs-shim">' + '' + '' + ''; diff --git a/src/js/me-utility.js b/src/js/me-utility.js index 383aa478b..cd3e70acd 100644 --- a/src/js/me-utility.js +++ b/src/js/me-utility.js @@ -110,7 +110,7 @@ mejs.Utility = { /* borrowed from SWFObject: http://code.google.com/p/swfobject/source/browse/trunk/swfobject/src/swfobject.js#474 */ removeSwf: function(id) { var obj = document.getElementById(id); - if (obj && obj.nodeName == "OBJECT") { + if (obj && /object|embed/i.test(obj.nodeName)) { if (mejs.MediaFeatures.isIE) { obj.style.display = "none"; (function(){ diff --git a/src/js/mep-feature-contextmenu.js b/src/js/mep-feature-contextmenu.js index f92a0bd33..f15d7a643 100644 --- a/src/js/mep-feature-contextmenu.js +++ b/src/js/mep-feature-contextmenu.js @@ -92,6 +92,10 @@ $.extend(mejs.MepDefaults, }); }, + + cleancontextmenu: function(player) { + player.contextMenu.remove(); + }, isContextMenuEnabled: true, enableContextMenu: function() { diff --git a/src/js/mep-feature-fullscreen.js b/src/js/mep-feature-fullscreen.js index 49c089f7b..689226709 100644 --- a/src/js/mep-feature-fullscreen.js +++ b/src/js/mep-feature-fullscreen.js @@ -27,15 +27,7 @@ if (mejs.MediaFeatures.hasTrueNativeFullScreen) { // chrome doesn't alays fire this in an iframe - var target = null; - - if (mejs.MediaFeatures.hasMozNativeFullScreen) { - target = $(document); - } else { - target = player.container; - } - - target.bind(mejs.MediaFeatures.fullScreenEventName, function(e) { + var func = function(e) { if (mejs.MediaFeatures.isFullScreen()) { player.isNativeFullScreen = true; @@ -47,7 +39,13 @@ // make sure to put the player back into place player.exitFullScreen(); } - }); + }; + + if (mejs.MediaFeatures.hasMozNativeFullScreen) { + player.globalBind(mejs.MediaFeatures.fullScreenEventName, func); + } else { + player.container.bind(mejs.MediaFeatures.fullScreenEventName, func); + } } var t = this, @@ -153,7 +151,7 @@ left: fullScreenBtnOffset + fullScreenBtnWidth}); }; - $(document).resize(function() { + t.globalBind('resize', function() { positionHoverDivs(); }); @@ -193,7 +191,7 @@ // the mouseout event doesn't work on the fullscren button, because we already killed the pointer-events // so we use the document.mousemove event to restore controls when the mouse moves outside the fullscreen button /* - $(document).mousemove(function(e) { + t.globalBind('mousemove', function(e) { // if the mouse is anywhere but the fullsceen button, then restore it all if (fullscreenIsDisabled) { @@ -251,13 +249,18 @@ player.fullscreenBtn = fullscreenBtn; - $(document).bind('keydown',function (e) { + t.globalBind('keydown',function (e) { if (((mejs.MediaFeatures.hasTrueNativeFullScreen && mejs.MediaFeatures.isFullScreen()) || t.isFullScreen) && e.keyCode == 27) { player.exitFullScreen(); } }); }, + + cleanfullscreen: function(player) { + player.exitFullScreen(); + }, + enterFullScreen: function() { var t = this; @@ -361,7 +364,7 @@ .width('100%') .height('100%'); } else { - t.container.find('object, embed, iframe') + t.container.find('.mejs-shim') .width('100%') .height('100%'); diff --git a/src/js/mep-feature-progress.js b/src/js/mep-feature-progress.js index 085536bc5..bfc1c4ce2 100644 --- a/src/js/mep-feature-progress.js +++ b/src/js/mep-feature-progress.js @@ -71,21 +71,20 @@ 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'); - }); + t.globalBind('mousemove.dur', function(e) { + handleMouseMove(e); + }); + t.globalBind('mouseup.dur', function (e) { + mouseIsDown = false; + timefloat.hide(); + t.globalUnbind('.dur'); + }); return false; } }) .bind('mouseenter', function(e) { mouseIsOver = true; - $(document).bind('mousemove.dur', function(e) { + t.globalBind('mousemove.dur', function(e) { handleMouseMove(e); }); if (!mejs.MediaFeatures.hasTouch) { @@ -95,7 +94,7 @@ .bind('mouseleave',function(e) { mouseIsOver = false; if (!mouseIsDown) { - $(document).unbind('.dur'); + t.globalUnbind('.dur'); timefloat.hide(); } }); diff --git a/src/js/mep-feature-volume.js b/src/js/mep-feature-volume.js index 228181621..52e2b6d2e 100644 --- a/src/js/mep-feature-volume.js +++ b/src/js/mep-feature-volume.js @@ -170,18 +170,17 @@ }) .bind('mousedown', function (e) { handleVolumeMove(e); - $(document) - .bind('mousemove.vol', function(e) { - handleVolumeMove(e); - }) - .bind('mouseup.vol', function () { - mouseIsDown = false; - $(document).unbind('.vol'); + t.globalBind('mousemove.vol', function(e) { + handleVolumeMove(e); + }); + t.globalBind('mouseup.vol', function () { + mouseIsDown = false; + t.globalUnbind('.vol'); - if (!mouseIsOver && mode == 'vertical') { - volumeSlider.hide(); - } - }); + if (!mouseIsOver && mode == 'vertical') { + volumeSlider.hide(); + } + }); mouseIsDown = true; return false; diff --git a/src/js/mep-player.js b/src/js/mep-player.js index 6e3d83609..f7fbd1d5b 100644 --- a/src/js/mep-player.js +++ b/src/js/mep-player.js @@ -50,6 +50,8 @@ autosizeProgress : true, // Hide controls when playing and mouse is not over the video alwaysShowControls: false, + // Display the video control + hideVideoControlsOnLoad: false, // Enable click video element to toggle play/pause clickToPlayPause: true, // force iPad's native controls @@ -151,7 +153,7 @@ mejs.mepIndex = 0; - mejs.players = []; + mejs.players = {}; // wraps a MediaElement object in player controls mejs.MediaElementPlayer = function(node, o) { @@ -183,8 +185,11 @@ // extend default options t.options = $.extend({},mejs.MepDefaults,o); + // unique ID + t.id = 'mep_' + mejs.mepIndex++; + // add to player array (for focus events) - mejs.players.push(t); + mejs.players[t.id] = t; // start up t.init(); @@ -247,9 +252,6 @@ // remove native controls t.$media.removeAttr('controls'); - // unique ID - t.id = 'mep_' + mejs.mepIndex++; - // build container t.container = $('
'+ @@ -588,7 +590,11 @@ } }); } - + + if(t.options.hideVideoControlsOnLoad) { + t.hideControls(false); + } + // check for autoplay if (autoplay && !t.options.alwaysShowControls) { t.hideControls(); @@ -612,10 +618,11 @@ // FOCUS: when a video starts playing, it takes focus from other players (possibily pausing them) media.addEventListener('play', function() { + var playerIndex; // go through all other players - for (var i=0, il=mejs.players.length; i or