iOS fixes

This commit is contained in:
Sam Potts 2016-01-15 15:07:31 +11:00
parent 9fbbb474db
commit 70b4b14984
3 changed files with 30 additions and 19 deletions

2
dist/plyr.css vendored

File diff suppressed because one or more lines are too long

2
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -286,9 +286,9 @@
} }
// Debugging // Debugging
function _log(text, error) { function _log(text, warn) {
if (config.debug && window.console) { if (config.debug && window.console) {
console[(error ? 'error' : 'log')](text); console[(warn ? 'warn' : 'log')](text);
} }
} }
@ -465,6 +465,9 @@
// Remove an element // Remove an element
function _remove(element) { function _remove(element) {
if(!element) {
return;
}
element.parentNode.removeChild(element); element.parentNode.removeChild(element);
} }
@ -879,7 +882,7 @@
var html = config.html; var html = config.html;
// Insert custom video controls // Insert custom video controls
_log('Injecting custom controls.'); _log('Injecting custom controls');
// If no controls are specified, create default // If no controls are specified, create default
if (!html) { if (!html) {
@ -971,7 +974,7 @@
return true; return true;
} }
catch(e) { catch(e) {
_log('It looks like there\'s a problem with your controls html. Bailing.', true); _log('It looks like there is a problem with your controls html', true);
// Restore native video controls // Restore native video controls
plyr.media.setAttribute('controls', ''); plyr.media.setAttribute('controls', '');
@ -996,7 +999,7 @@
} }
// If there's a play button, set label // If there's a play button, set label
if (plyr.buttons.play) { if (plyr.supported.full && plyr.buttons.play) {
plyr.buttons.play.setAttribute('aria-label', label); plyr.buttons.play.setAttribute('aria-label', label);
} }
@ -1011,7 +1014,7 @@
function _setupMedia() { function _setupMedia() {
// If there's no media, bail // If there's no media, bail
if (!plyr.media) { if (!plyr.media) {
_log('No audio or video element found!', true); _log('No audio or video element found', true);
return false; return false;
} }
@ -1382,7 +1385,7 @@
plyr.captionExists = true; plyr.captionExists = true;
if (captionSrc === '') { if (captionSrc === '') {
plyr.captionExists = false; plyr.captionExists = false;
_log('No caption track found.'); _log('No caption track found');
} }
else { else {
_log('Caption track found; URI: ' + captionSrc); _log('Caption track found; URI: ' + captionSrc);
@ -1410,7 +1413,7 @@
(plyr.browser.name === 'Chrome' && plyr.browser.version >= 43) || (plyr.browser.name === 'Chrome' && plyr.browser.version >= 43) ||
(plyr.browser.name === 'Safari' && plyr.browser.version >= 7)) { (plyr.browser.name === 'Safari' && plyr.browser.version >= 7)) {
// Debugging // Debugging
_log('Detected unsupported browser for HTML5 captions. Using fallback.'); _log('Detected unsupported browser for HTML5 captions - using fallback');
// Set to false so skips to 'manual' captioning // Set to false so skips to 'manual' captioning
plyr.usingTextTracks = false; plyr.usingTextTracks = false;
@ -1419,7 +1422,7 @@
// Rendering caption tracks // Rendering caption tracks
// Native support required - http://caniuse.com/webvtt // Native support required - http://caniuse.com/webvtt
if (plyr.usingTextTracks) { if (plyr.usingTextTracks) {
_log('TextTracks supported.'); _log('TextTracks supported');
for (var y = 0; y < tracks.length; y++) { for (var y = 0; y < tracks.length; y++) {
var track = tracks[y]; var track = tracks[y];
@ -1439,7 +1442,7 @@
} }
// Caption tracks not natively supported // Caption tracks not natively supported
else { else {
_log('TextTracks not supported so rendering captions manually.'); _log('TextTracks not supported so rendering captions manually');
// Render captions from array at appropriate time // Render captions from array at appropriate time
plyr.currentCaption = ''; plyr.currentCaption = '';
@ -1467,10 +1470,10 @@
// Remove first element ('VTT') // Remove first element ('VTT')
plyr.captions.shift(); plyr.captions.shift();
_log('Successfully loaded the caption file via AJAX.'); _log('Successfully loaded the caption file via AJAX');
} }
else { else {
_log('There was a problem loading the caption file via AJAX.', true); _log('There was a problem loading the caption file via AJAX', true);
} }
} }
}; };
@ -1483,7 +1486,7 @@
// If Safari 7+, removing track from DOM [see 'turn off native caption rendering' above] // If Safari 7+, removing track from DOM [see 'turn off native caption rendering' above]
if (plyr.browser.name === 'Safari' && plyr.browser.version >= 7) { if (plyr.browser.name === 'Safari' && plyr.browser.version >= 7) {
_log('Safari 7+ detected; removing track from DOM.'); _log('Safari 7+ detected; removing track from DOM');
// Find all <track> elements // Find all <track> elements
tracks = plyr.media.getElementsByTagName('track'); tracks = plyr.media.getElementsByTagName('track');
@ -1507,13 +1510,13 @@
var nativeSupport = fullscreen.supportsFullScreen; var nativeSupport = fullscreen.supportsFullScreen;
if (nativeSupport || (config.fullscreen.fallback && !_inFrame())) { if (nativeSupport || (config.fullscreen.fallback && !_inFrame())) {
_log((nativeSupport ? 'Native' : 'Fallback') + ' fullscreen enabled.'); _log((nativeSupport ? 'Native' : 'Fallback') + ' fullscreen enabled');
// Add styling hook // Add styling hook
_toggleClass(plyr.container, config.classes.fullscreen.enabled, true); _toggleClass(plyr.container, config.classes.fullscreen.enabled, true);
} }
else { else {
_log('Fullscreen not supported and fallback disabled.'); _log('Fullscreen not supported and fallback disabled');
} }
// Toggle state // Toggle state
@ -2074,6 +2077,9 @@
} }
} }
// Check for support
plyr.supported = api.supported(plyr.type);
// Create new markup // Create new markup
switch(plyr.type) { switch(plyr.type) {
case 'video': case 'video':
@ -2397,7 +2403,7 @@
config.loop = (config.loop || (plyr.media.getAttribute('loop') !== null)); config.loop = (config.loop || (plyr.media.getAttribute('loop') !== null));
} }
// Check for full support // Check for support
plyr.supported = api.supported(plyr.type); plyr.supported = api.supported(plyr.type);
// Add style hook // Add style hook
@ -2439,11 +2445,16 @@
function _setupInterface() { function _setupInterface() {
// Don't setup interface if no support // Don't setup interface if no support
if (!plyr.supported.full) { if (!plyr.supported.full) {
_log("No full support for this media type (" + plyr.type + ")", true);
// Remove controls
_remove(_getElement(config.selectors.controls.wrapper));
return; return;
} }
// Inject custom controls // Inject custom controls
if (!plyr.container.querySelectorAll(config.selectors.controls.wrapper).length) { if (!_getElements(config.selectors.controls.wrapper).length) {
// Inject custom controls // Inject custom controls
_injectControls(); _injectControls();
} }