Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2072 from vogdb/issue-2072
Browse files Browse the repository at this point in the history
Throw errors of createAudioPlayer
  • Loading branch information
vogdb committed Jan 25, 2016
2 parents 5e4dd6a + 2a70457 commit d6709fc
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 76 deletions.
148 changes: 80 additions & 68 deletions client-vendor/after-body/mediaelement/mediaelement-and-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var mejs = mejs || {};

// version number
mejs.version = '2.18.1';
mejs.version = '2.19.0';


// player number (for missing, same id attr)
Expand Down Expand Up @@ -182,6 +182,18 @@ mejs.Utility = {
time = 0;
}

// Maintain backward compatibility with method signature before v2.18.
if (typeof options !== 'object') {
var format = 'm:ss';
format = arguments[1] ? 'hh:mm:ss' : format; // forceHours
format = arguments[2] ? format + ':ff' : format; // showFrameCount

options = {
currentTimeFormat: format,
framesPerSecond: arguments[3] || 25
};
}

var fps = options.framesPerSecond;
if(typeof fps === 'undefined') {
fps = 25;
Expand Down Expand Up @@ -413,16 +425,17 @@ mejs.MediaFeatures = {
t.isGecko = (ua.match(/gecko/gi) !== null) && !t.isWebkit && !t.isIE;
t.isOpera = (ua.match(/opera/gi) !== null);
t.hasTouch = ('ontouchstart' in window); // && window.ontouchstart != null); // this breaks iOS 7

// borrowed from Modernizr
t.svg = !! document.createElementNS &&
!! document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect;

// Borrowed from `Modernizr.svgasimg`, sources:
// - https://github.com/Modernizr/Modernizr/issues/687
// - https://github.com/Modernizr/Modernizr/pull/1209/files
t.svgAsImg = !!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1');

// create HTML5 media elements for IE before 9, get a <video> element for fullscreen detection
for (i=0; i<html5Elements.length; i++) {
v = document.createElement(html5Elements[i]);
}

t.supportsMediaTag = (typeof v.canPlayType !== 'undefined' || t.isBustedAndroid);

// Fix for IE9 on Windows 7N / Windows 7KN (Media Player not installer)
Expand All @@ -433,62 +446,62 @@ mejs.MediaFeatures = {
}

// detect native JavaScript fullscreen (Safari/Firefox only, Chrome still fails)

// iOS
t.hasSemiNativeFullScreen = (typeof v.webkitEnterFullscreen !== 'undefined');

// W3C
t.hasNativeFullscreen = (typeof v.requestFullscreen !== 'undefined');

// webkit/firefox/IE11+
t.hasWebkitNativeFullScreen = (typeof v.webkitRequestFullScreen !== 'undefined');
t.hasMozNativeFullScreen = (typeof v.mozRequestFullScreen !== 'undefined');
t.hasMsNativeFullScreen = (typeof v.msRequestFullscreen !== 'undefined');

t.hasTrueNativeFullScreen = (t.hasWebkitNativeFullScreen || t.hasMozNativeFullScreen || t.hasMsNativeFullScreen);
t.nativeFullScreenEnabled = t.hasTrueNativeFullScreen;

// Enabled?
if (t.hasMozNativeFullScreen) {
t.nativeFullScreenEnabled = document.mozFullScreenEnabled;
} else if (t.hasMsNativeFullScreen) {
t.nativeFullScreenEnabled = document.msFullscreenEnabled;
t.nativeFullScreenEnabled = document.msFullscreenEnabled;
}

if (t.isChrome) {
t.hasSemiNativeFullScreen = false;
}

if (t.hasTrueNativeFullScreen) {

t.fullScreenEventName = '';
if (t.hasWebkitNativeFullScreen) {
if (t.hasWebkitNativeFullScreen) {
t.fullScreenEventName = 'webkitfullscreenchange';

} else if (t.hasMozNativeFullScreen) {
t.fullScreenEventName = 'mozfullscreenchange';

} else if (t.hasMsNativeFullScreen) {
t.fullScreenEventName = 'MSFullscreenChange';
}

t.isFullScreen = function() {
if (t.hasMozNativeFullScreen) {
return d.mozFullScreen;

} else if (t.hasWebkitNativeFullScreen) {
return d.webkitIsFullScreen;

} else if (t.hasMsNativeFullScreen) {
return d.msFullscreenElement !== null;
}
}

t.requestFullScreen = function(el) {

if (t.hasWebkitNativeFullScreen) {
el.webkitRequestFullScreen();

} else if (t.hasMozNativeFullScreen) {
el.mozRequestFullScreen();

Expand All @@ -497,29 +510,29 @@ mejs.MediaFeatures = {

}
}
t.cancelFullScreen = function() {

t.cancelFullScreen = function() {
if (t.hasWebkitNativeFullScreen) {
document.webkitCancelFullScreen();

} else if (t.hasMozNativeFullScreen) {
document.mozCancelFullScreen();

} else if (t.hasMsNativeFullScreen) {
document.msExitFullscreen();

}
}
}

}


// OS X 10.5 can't do this even if it says it can :(
if (t.hasSemiNativeFullScreen && ua.match(/mac os x 10_5/i)) {
t.hasNativeFullScreen = false;
t.hasSemiNativeFullScreen = false;
}

}
};
mejs.MediaFeatures.init();
Expand Down Expand Up @@ -1001,7 +1014,7 @@ mejs.HtmlMediaElementShim = {

create: function(el, o) {
var
options = mejs.MediaElementDefaults,
options = {},
htmlMediaElement = (typeof(el) == 'string') ? document.getElementById(el) : el,
tagName = htmlMediaElement.tagName.toLowerCase(),
isMediaTag = (tagName === 'audio' || tagName === 'video'),
Expand All @@ -1014,9 +1027,13 @@ mejs.HtmlMediaElementShim = {
prop;

// extend options
for (prop in mejs.MediaElementDefaults) {
options[prop] = mejs.MediaElementDefaults[prop];
}
for (prop in o) {
options[prop] = o[prop];
}
}


// clean up attributes
src = (typeof src == 'undefined' || src === null || src == '') ? null : src;
Expand Down Expand Up @@ -2367,8 +2384,8 @@ if (typeof jQuery != 'undefined') {
$('<span class="mejs-offscreen">' + videoPlayerTitle + '</span>').insertBefore(t.$media);
// build container
t.container =
$('<div id="' + t.id + '" class="mejs-container ' + (mejs.MediaFeatures.svg ? 'svg' : 'no-svg') +
'" tabindex="0" role="application" aria-label="' + videoPlayerTitle + '">'+
$('<div id="' + t.id + '" class="mejs-container ' + (mejs.MediaFeatures.svgAsImg ? 'svg' : 'no-svg') +
'" tabindex="0" role="application" aria-label="' + videoPlayerTitle + '">'+
'<div class="mejs-inner">'+
'<div class="mejs-mediaelement"></div>'+
'<div class="mejs-layers"></div>'+
Expand Down Expand Up @@ -2397,23 +2414,8 @@ if (typeof jQuery != 'undefined') {


// move the <video/video> tag into the right spot
if (mf.isiOS) {

// sadly, you can't move nodes in iOS, so we have to destroy and recreate it!
var $newMedia = t.$media.clone();
t.container.find('.mejs-mediaelement').append(t.$media);

t.container.find('.mejs-mediaelement').append($newMedia);

t.$media.remove();
t.$node = t.$media = $newMedia;
t.node = t.media = $newMedia[0];

} else {

// normal way of moving it into place (doesn't work on iOS)
t.container.find('.mejs-mediaelement').append(t.$media);
}

// needs to be assigned here, after iOS remap
t.node.player = t;

Expand Down Expand Up @@ -2695,7 +2697,7 @@ if (typeof jQuery != 'undefined') {

// show/hide controls
t.container
.bind('mouseenter mouseover', function () {
.bind('mouseenter', function () {
if (t.controlsEnabled) {
if (!t.options.alwaysShowControls ) {
t.killControlsTimer('enter');
Expand Down Expand Up @@ -2808,15 +2810,15 @@ if (typeof jQuery != 'undefined') {
t.setControlsSize();
}
}, false);

// Only change the time format when necessary
var duration = null;
t.media.addEventListener('timeupdate',function() {
if (duration !== this.duration) {
duration = this.duration;
mejs.Utility.calculateTimeFormat(duration, t.options, t.options.framesPerSecond || 25);
}
}, false);
}, false);

t.container.focusout(function (e) {
if( e.relatedTarget ) { //FF is working on supporting focusout https://bugzilla.mozilla.org/show_bug.cgi?id=687787
Expand Down Expand Up @@ -2873,7 +2875,9 @@ if (typeof jQuery != 'undefined') {
handleError: function(e) {
var t = this;

t.controls.hide();
if (t.controls) {
t.controls.hide();
}

// Tell user that the file cannot be played
if (t.options.error) {
Expand Down Expand Up @@ -3211,8 +3215,9 @@ if (typeof jQuery != 'undefined') {
});

// listen for key presses
t.globalBind('keydown', function(e) {
return t.onkeydown(player, media, e);
t.globalBind('keydown', function(event) {
player.hasFocus = $(event.target).closest('.mejs-container').length !== 0;
return t.onkeydown(player, media, event);
});


Expand Down Expand Up @@ -3302,7 +3307,7 @@ if (typeof jQuery != 'undefined') {
},
remove: function() {
var t = this, featureIndex, feature;

t.container.prev('.mejs-offscreen').remove();

// invoke features cleanup
Expand Down Expand Up @@ -3357,7 +3362,7 @@ if (typeof jQuery != 'undefined') {
//
t.setPlayerSize(t.width, t.height);
t.setControlsSize();
}, 50);
}, 50);
}
};

Expand All @@ -3383,16 +3388,20 @@ if (typeof jQuery != 'undefined') {
}

mejs.MediaElementPlayer.prototype.globalBind = function(events, data, callback) {
var t = this;
var t = this;
var doc = t.node ? t.node.ownerDocument : document;

events = splitEvents(events, t.id);
if (events.d) $(document).bind(events.d, data, callback);
if (events.d) $(doc).bind(events.d, data, callback);
if (events.w) $(window).bind(events.w, data, callback);
};

mejs.MediaElementPlayer.prototype.globalUnbind = function(events, callback) {
var t = this;
var doc = t.node ? t.node.ownerDocument : document;

events = splitEvents(events, t.id);
if (events.d) $(document).unbind(events.d, callback);
if (events.d) $(doc).unbind(events.d, callback);
if (events.w) $(window).unbind(events.w, callback);
};
})();
Expand Down Expand Up @@ -4126,9 +4135,6 @@ if (typeof jQuery != 'undefined') {
positionVolumeHandle(volume);
media.setVolume(volume);
return false;
})
.bind('blur', function () {
volumeSlider.hide();
});

// MUTE button
Expand Down Expand Up @@ -4758,6 +4764,12 @@ if (typeof jQuery != 'undefined') {

playbackSpeed = t.options.defaultSpeed;

media.addEventListener('loadedmetadata', function(e) {
if (playbackSpeed) {
media.playbackRate = parseFloat(playbackSpeed);
}
}, true);

speedSelector
.on('click', 'input[type="radio"]', function() {
var newSpeed = $(this).attr('value');
Expand Down
Loading

0 comments on commit d6709fc

Please sign in to comment.