Skip to content

Commit

Permalink
Merge pull request #9 from nbibler/me2.9.1
Browse files Browse the repository at this point in the history
Update to MediaElement.js version 2.9.1
  • Loading branch information
petebrowne committed Jun 18, 2012
2 parents 533a400 + 7b27006 commit d2c5d3f
Show file tree
Hide file tree
Showing 6 changed files with 422 additions and 145 deletions.
Binary file modified app/assets/images/mediaelement_rails/controls.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 41 additions & 8 deletions app/assets/javascripts/mediaelement_rails/mediaelement.js
Expand Up @@ -7,15 +7,15 @@
* for browsers that don't understand HTML5 or can't play the provided codec * for browsers that don't understand HTML5 or can't play the provided codec
* Can play MP4 (H.264), Ogg, WebM, FLV, WMV, WMA, ACC, and MP3 * Can play MP4 (H.264), Ogg, WebM, FLV, WMV, WMA, ACC, and MP3
* *
* Copyright 2010-2011, John Dyer (http://j.hn) * Copyright 2010-2012, John Dyer (http://j.hn)
* Dual licensed under the MIT or GPL Version 2 licenses. * Dual licensed under the MIT or GPL Version 2 licenses.
* *
*/ */
// Namespace // Namespace
var mejs = mejs || {}; var mejs = mejs || {};


// version number // version number
mejs.version = '2.6.5'; mejs.version = '2.9.1';


// player number (for missing, same id attr) // player number (for missing, same id attr)
mejs.meIndex = 0; mejs.meIndex = 0;
Expand All @@ -26,11 +26,11 @@ mejs.plugins = {
{version: [3,0], types: ['video/mp4','video/m4v','video/mov','video/wmv','audio/wma','audio/m4a','audio/mp3','audio/wav','audio/mpeg']} {version: [3,0], types: ['video/mp4','video/m4v','video/mov','video/wmv','audio/wma','audio/m4a','audio/mp3','audio/wav','audio/mpeg']}
], ],
flash: [ flash: [
{version: [9,0,124], types: ['video/mp4','video/m4v','video/mov','video/flv','video/x-flv','audio/flv','audio/x-flv','audio/mp3','audio/m4a','audio/mpeg']} {version: [9,0,124], types: ['video/mp4','video/m4v','video/mov','video/flv','video/x-flv','audio/flv','audio/x-flv','audio/mp3','audio/m4a','audio/mpeg', 'video/youtube', 'video/x-youtube']}
//,{version: [12,0], types: ['video/webm']} // for future reference (hopefully!) //,{version: [12,0], types: ['video/webm']} // for future reference (hopefully!)
], ],
youtube: [ youtube: [
{version: null, types: ['video/youtube']} {version: null, types: ['video/youtube', 'video/x-youtube']}
], ],
vimeo: [ vimeo: [
{version: null, types: ['video/vimeo']} {version: null, types: ['video/vimeo']}
Expand Down Expand Up @@ -59,11 +59,13 @@ mejs.Utility = {
path = '', path = '',
name = '', name = '',
script, script,
scripts = document.getElementsByTagName('script'); scripts = document.getElementsByTagName('script'),
il = scripts.length,
jl = scriptNames.length;


for (; i < scripts.length; i++) { for (; i < il; i++) {
script = scripts[i].src; script = scripts[i].src;
for (j = 0; j < scriptNames.length; j++) { for (j = 0; j < jl; j++) {
name = scriptNames[j]; name = scriptNames[j];
if (script.indexOf(name) > -1) { if (script.indexOf(name) > -1) {
path = script.substring(0, script.indexOf(name)); path = script.substring(0, script.indexOf(name));
Expand Down Expand Up @@ -436,6 +438,7 @@ mejs.PluginMediaElement.prototype = {
seeking: false, seeking: false,
duration: 0, duration: 0,
error: null, error: null,
tagName: '',


// HTML5 get/set properties, but only set (updated by event handlers) // HTML5 get/set properties, but only set (updated by event handlers)
muted: false, muted: false,
Expand Down Expand Up @@ -650,6 +653,24 @@ mejs.PluginMediaElement.prototype = {
}, },
// end: fake events // end: fake events


// fake DOM attribute methods
attributes: {},
hasAttribute: function(name){
return (name in this.attributes);
},
removeAttribute: function(name){
delete this.attributes[name];
},
getAttribute: function(name){
if (this.hasAttribute(name)) {
return this.attributes[name];
}
return '';
},
setAttribute: function(name, value){
this.attributes[name] = value;
},

remove: function() { remove: function() {
mejs.Utility.removeSwf(this.pluginElement.id); mejs.Utility.removeSwf(this.pluginElement.id);
} }
Expand Down Expand Up @@ -1021,7 +1042,7 @@ mejs.HtmlMediaElementShim = {
} catch (e) {} } catch (e) {}


errorContainer.innerHTML = (poster !== '') ? errorContainer.innerHTML = (poster !== '') ?
'<a href="' + playback.url + '"><img src="' + poster + '" /></a>' : '<a href="' + playback.url + '"><img src="' + poster + '" width="100%" height="100%" /></a>' :
'<a href="' + playback.url + '"><span>Download File</span></a>'; '<a href="' + playback.url + '"><span>Download File</span></a>';


htmlMediaElement.parentNode.insertBefore(errorContainer, htmlMediaElement); htmlMediaElement.parentNode.insertBefore(errorContainer, htmlMediaElement);
Expand All @@ -1042,6 +1063,17 @@ mejs.HtmlMediaElementShim = {
node, node,
initVars; initVars;


// copy tagName from html media element
pluginMediaElement.tagName = htmlMediaElement.tagName

// copy attributes from html media element to plugin media element
for (var i = 0; i < htmlMediaElement.attributes.length; i++) {
var attribute = htmlMediaElement.attributes[i];
if (attribute.specified == true) {
pluginMediaElement.setAttribute(attribute.name, attribute.value);
}
}

// check for placement inside a <p> tag (sometimes WYSIWYG editors do this) // check for placement inside a <p> tag (sometimes WYSIWYG editors do this)
node = htmlMediaElement.parentNode; node = htmlMediaElement.parentNode;
while (node !== null && node.tagName.toLowerCase() != 'body') { while (node !== null && node.tagName.toLowerCase() != 'body') {
Expand Down Expand Up @@ -1361,6 +1393,7 @@ mejs.YouTubeApi = {


iFrameReady: function() { iFrameReady: function() {


this.isLoaded = true;
this.isIframeLoaded = true; this.isIframeLoaded = true;


while (this.iframeQueue.length > 0) { while (this.iframeQueue.length > 0) {
Expand Down

0 comments on commit d2c5d3f

Please sign in to comment.