JsBeautifier in use, syntax tweaks
This commit is contained in:
parent
bce1d983cb
commit
5a0cb9289c
@ -6,6 +6,27 @@
|
||||
"allowed_file_extensions": []
|
||||
},
|
||||
"js": {
|
||||
"allowed_file_extensions": []
|
||||
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
|
||||
"brace_style": "collapse",
|
||||
"break_chained_methods": false,
|
||||
"e4x": false,
|
||||
"end_with_newline": false,
|
||||
"indent_char": " ",
|
||||
"indent_level": 0,
|
||||
"indent_size": 4,
|
||||
"indent_with_tabs": false,
|
||||
"jslint_happy": false,
|
||||
"keep_array_indentation": true,
|
||||
"keep_function_indentation": true,
|
||||
"max_preserve_newlines": 2,
|
||||
"preserve_newlines": true,
|
||||
"space_after_anon_function": false,
|
||||
"space_before_conditional": true,
|
||||
"space_in_empty_paren": false,
|
||||
"space_in_paren": false,
|
||||
"unescape_strings": false,
|
||||
"wrap_line_length": 0,
|
||||
"wrap_attributes": "auto",
|
||||
"wrap_attributes_indent_size": 4
|
||||
}
|
||||
}
|
||||
|
4
dist/plyr.js
vendored
4
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
301
src/js/plyr.js
301
src/js/plyr.js
@ -7,7 +7,7 @@
|
||||
// Credits: http://paypal.github.io/accessible-html5-video-player/
|
||||
// ==========================================================================
|
||||
|
||||
;(function(root, factory) {
|
||||
(function(root, factory) {
|
||||
'use strict';
|
||||
/* global define,module */
|
||||
|
||||
@ -16,7 +16,9 @@
|
||||
module.exports = factory(root, document);
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define([], function () { return factory(root, document); });
|
||||
define([], function() {
|
||||
return factory(root, document);
|
||||
});
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.plyr = factory(root, document);
|
||||
@ -25,7 +27,10 @@
|
||||
'use strict';
|
||||
|
||||
// Globals
|
||||
var scroll = { x: 0, y: 0 },
|
||||
var scroll = {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
|
||||
// Default config
|
||||
defaults = {
|
||||
@ -198,17 +203,17 @@
|
||||
// Credits: http://paypal.github.io/accessible-html5-video-player/
|
||||
// Unfortunately, due to mixed support, UA sniffing is required
|
||||
function _getBrowser() {
|
||||
var ua = navigator.userAgent,
|
||||
name = navigator.appName,
|
||||
fullVersion = '' + parseFloat(navigator.appVersion),
|
||||
majorVersion = parseInt(navigator.appVersion, 10),
|
||||
nameOffset,
|
||||
verOffset,
|
||||
ix,
|
||||
isIE = false,
|
||||
isFirefox = false,
|
||||
isChrome = false,
|
||||
isSafari = false;
|
||||
var ua = navigator.userAgent;
|
||||
var name = navigator.appName;
|
||||
var fullVersion = '' + parseFloat(navigator.appVersion);
|
||||
var majorVersion = parseInt(navigator.appVersion, 10);
|
||||
var nameOffset;
|
||||
var verOffset;
|
||||
var ix;
|
||||
var isIE = false;
|
||||
var isFirefox = false;
|
||||
var isChrome = false;
|
||||
var isSafari = false;
|
||||
|
||||
if ((navigator.appVersion.indexOf('Windows NT') !== -1) && (navigator.appVersion.indexOf('rv:11') !== -1)) {
|
||||
// MSIE 11
|
||||
@ -230,6 +235,7 @@
|
||||
isSafari = true;
|
||||
name = 'Safari';
|
||||
fullVersion = ua.substring(verOffset + 7);
|
||||
|
||||
if ((verOffset = ua.indexOf('Version')) !== -1) {
|
||||
fullVersion = ua.substring(verOffset + 8);
|
||||
}
|
||||
@ -284,6 +290,7 @@
|
||||
|
||||
var tag = document.createElement('script');
|
||||
tag.src = source;
|
||||
|
||||
var firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
}
|
||||
@ -395,13 +402,17 @@
|
||||
|
||||
// Element matches selector
|
||||
function _matches(element, selector) {
|
||||
var p = Element.prototype;
|
||||
var prototype = Element.prototype;
|
||||
|
||||
var f = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || function(s) {
|
||||
var matches = prototype.matches ||
|
||||
prototype.webkitMatchesSelector ||
|
||||
prototype.mozMatchesSelector ||
|
||||
prototype.msMatchesSelector ||
|
||||
function(s) {
|
||||
return [].indexOf.call(document.querySelectorAll(s), this) !== -1;
|
||||
};
|
||||
|
||||
return f.call(element, selector);
|
||||
return matches.call(element, selector);
|
||||
}
|
||||
|
||||
// Bind along with custom handler
|
||||
@ -689,8 +700,7 @@
|
||||
|
||||
// Check if value matches
|
||||
return (result === 'OK');
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -721,19 +731,24 @@
|
||||
// Type specific checks
|
||||
if (plyr.type === 'video') {
|
||||
switch (type) {
|
||||
case 'video/webm': return media.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/, '');
|
||||
case 'video/mp4': return media.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, '');
|
||||
case 'video/ogg': return media.canPlayType('video/ogg; codecs="theora"').replace(/no/, '');
|
||||
case 'video/webm':
|
||||
return media.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/, '');
|
||||
case 'video/mp4':
|
||||
return media.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, '');
|
||||
case 'video/ogg':
|
||||
return media.canPlayType('video/ogg; codecs="theora"').replace(/no/, '');
|
||||
}
|
||||
} else if (plyr.type === 'audio') {
|
||||
switch (type) {
|
||||
case 'audio/mpeg': return media.canPlayType('audio/mpeg;').replace(/no/, '');
|
||||
case 'audio/ogg': return media.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '');
|
||||
case 'audio/wav': return media.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
|
||||
case 'audio/mpeg':
|
||||
return media.canPlayType('audio/mpeg;').replace(/no/, '');
|
||||
case 'audio/ogg':
|
||||
return media.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '');
|
||||
case 'audio/wav':
|
||||
return media.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -744,9 +759,9 @@
|
||||
|
||||
// Player instance
|
||||
function Plyr(media, config) {
|
||||
var plyr = this,
|
||||
timers = {},
|
||||
api;
|
||||
var plyr = this;
|
||||
var timers = {};
|
||||
var api;
|
||||
|
||||
// Set media
|
||||
plyr.media = media;
|
||||
@ -771,8 +786,12 @@
|
||||
console[type].apply(console, args);
|
||||
}
|
||||
}
|
||||
var _log = function() { _console('log', arguments) },
|
||||
_warn = function() { _console('warn', arguments) };
|
||||
var _log = function() {
|
||||
_console('log', arguments)
|
||||
};
|
||||
var _warn = function() {
|
||||
_console('warn', arguments)
|
||||
};
|
||||
|
||||
// Log config options
|
||||
_log('Config', config);
|
||||
@ -788,45 +807,52 @@
|
||||
// Build the default HTML
|
||||
function _buildControls() {
|
||||
// Create html array
|
||||
var html = [],
|
||||
iconUrl = _getIconUrl(),
|
||||
iconPath = (!iconUrl.absolute ? iconUrl.url : '') + '#' + config.iconPrefix;
|
||||
var html = [];
|
||||
var iconUrl = _getIconUrl();
|
||||
var iconPath = (!iconUrl.absolute ? iconUrl.url : '') + '#' + config.iconPrefix;
|
||||
|
||||
// Larger overlaid play button
|
||||
if (_inArray(config.controls, 'play-large')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" data-plyr="play" class="plyr__play-large">',
|
||||
'<svg><use xlink:href="' + iconPath + '-play" /></svg>',
|
||||
'<span class="plyr__sr-only">' + config.i18n.play + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
html.push('<div class="plyr__controls">');
|
||||
|
||||
// Restart button
|
||||
if (_inArray(config.controls, 'restart')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="restart">',
|
||||
'<svg><use xlink:href="' + iconPath + '-restart" /></svg>',
|
||||
'<span class="plyr__sr-only">' + config.i18n.restart + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Rewind button
|
||||
if (_inArray(config.controls, 'rewind')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="rewind">',
|
||||
'<svg><use xlink:href="' + iconPath + '-rewind" /></svg>',
|
||||
'<span class="plyr__sr-only">' + config.i18n.rewind + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Play Pause button
|
||||
// TODO: This should be a toggle button really?
|
||||
if (_inArray(config.controls, 'play')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="play">',
|
||||
'<svg><use xlink:href="' + iconPath + '-play" /></svg>',
|
||||
@ -837,28 +863,35 @@
|
||||
'<span class="plyr__sr-only">' + config.i18n.pause + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Fast forward button
|
||||
if (_inArray(config.controls, 'fast-forward')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="fast-forward">',
|
||||
'<svg><use xlink:href="' + iconPath + '-fast-forward" /></svg>',
|
||||
'<span class="plyr__sr-only">' + config.i18n.forward + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Progress
|
||||
if (_inArray(config.controls, 'progress')) {
|
||||
// Create progress
|
||||
html.push('<span class="plyr__progress">',
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<span class="plyr__progress">',
|
||||
'<label for="seek-{id}" class="plyr__sr-only">Seek</label>',
|
||||
'<input id="seek-{id}" class="plyr__progress--seek" type="range" min="0" max="100" step="0.1" value="0" data-plyr="seek">',
|
||||
'<progress class="plyr__progress--played" max="100" value="0" role="presentation"></progress>',
|
||||
'<progress class="plyr__progress--buffer" max="100" value="0">',
|
||||
'<span>0</span>% ' + config.i18n.buffered,
|
||||
'</progress>');
|
||||
'</progress>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
|
||||
// Seek tooltip
|
||||
if (config.tooltips.seek) {
|
||||
@ -871,26 +904,31 @@
|
||||
|
||||
// Media current time display
|
||||
if (_inArray(config.controls, 'current-time')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<span class="plyr__time">',
|
||||
'<span class="plyr__sr-only">' + config.i18n.currentTime + '</span>',
|
||||
'<span class="plyr__time--current">00:00</span>',
|
||||
'</span>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Media duration display
|
||||
if (_inArray(config.controls, 'duration')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<span class="plyr__time">',
|
||||
'<span class="plyr__sr-only">' + config.i18n.duration + '</span>',
|
||||
'<span class="plyr__time--duration">00:00</span>',
|
||||
'</span>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Toggle mute button
|
||||
if (_inArray(config.controls, 'mute')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="mute">',
|
||||
'<svg class="icon--muted"><use xlink:href="' + iconPath + '-muted" /></svg>',
|
||||
@ -898,10 +936,12 @@
|
||||
'<span class="plyr__sr-only">' + config.i18n.toggleMute + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Volume range control
|
||||
if (_inArray(config.controls, 'volume')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<span class="plyr__volume">',
|
||||
'<label for="volume-{id}" class="plyr__sr-only">' + config.i18n.volume + '</label>',
|
||||
@ -909,10 +949,12 @@
|
||||
'<progress class="plyr__volume--display" max="' + config.volumeMax + '" value="' + config.volumeMin + '" role="presentation"></progress>',
|
||||
'</span>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Toggle captions button
|
||||
if (_inArray(config.controls, 'captions')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="captions">',
|
||||
'<svg class="icon--captions-on"><use xlink:href="' + iconPath + '-captions-on" /></svg>',
|
||||
@ -920,10 +962,12 @@
|
||||
'<span class="plyr__sr-only">' + config.i18n.toggleCaptions + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Settings button / menu
|
||||
if (_inArray(config.controls, 'settings')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<div class="plyr__menu" data-plyr="settings">',
|
||||
'<button type="button" id="plyr-settings-toggle-{id}" class="plyr__control" aria-haspopup="true" aria-controls="plyr-settings-{id}" aria-expanded="false">',
|
||||
@ -936,17 +980,20 @@
|
||||
'<ul>',
|
||||
'<li role="tab">',
|
||||
'<button type="button" class="plyr__control plyr__control--forward" id="plyr-settings-{id}-captions-toggle" aria-haspopup="true" aria-controls="plyr-settings-{id}-captions" aria-expanded="false">',
|
||||
config.i18n.captions + ' <span class="plyr__menu__value">{lang}</span>',
|
||||
config.i18n.captions +
|
||||
'<span class="plyr__menu__value">{lang}</span>',
|
||||
'</button>',
|
||||
'</li>',
|
||||
'<li role="tab">',
|
||||
'<button type="button" class="plyr__control plyr__control--forward" id="plyr-settings-{id}-speed-toggle" aria-haspopup="true" aria-controls="plyr-settings-{id}-speed" aria-expanded="false">',
|
||||
config.i18n.speed + ' <span class="plyr__menu__value">{speed}</span>',
|
||||
config.i18n.speed +
|
||||
'<span class="plyr__menu__value">{speed}</span>',
|
||||
'</button>',
|
||||
'</li>',
|
||||
'<li role="tab">',
|
||||
'<button type="button" class="plyr__control plyr__control--forward" id="plyr-settings-{id}-quality-toggle" aria-haspopup="true" aria-controls="plyr-settings-{id}-quality" aria-expanded="false">',
|
||||
config.i18n.quality + ' <span class="plyr__menu__value">Auto</span>',
|
||||
config.i18n.quality +
|
||||
'<span class="plyr__menu__value">Auto</span>',
|
||||
'</button>',
|
||||
'</li>',
|
||||
'</ul>',
|
||||
@ -1048,30 +1095,36 @@
|
||||
'</div>',
|
||||
'</div>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Picture in picture button
|
||||
if (_inArray(config.controls, 'pip') && _support.pip) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="pip">',
|
||||
'<svg><use xlink:href="' + iconPath + '-pip" /></svg>',
|
||||
'<span class="plyr__sr-only">PIP</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Airplay button
|
||||
if (_inArray(config.controls, 'airplay') && _support.airplay) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="airplay">',
|
||||
'<svg><use xlink:href="' + iconPath + '-airplay" /></svg>',
|
||||
'<span class="plyr__sr-only">AirPlay</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Toggle fullscreen button
|
||||
if (_inArray(config.controls, 'fullscreen')) {
|
||||
/* beautify ignore:start */
|
||||
html.push(
|
||||
'<button type="button" class="plyr__control" data-plyr="fullscreen">',
|
||||
'<svg class="icon--exit-fullscreen"><use xlink:href="' + iconPath + '-exit-fullscreen" /></svg>',
|
||||
@ -1079,6 +1132,7 @@
|
||||
'<span class="plyr__sr-only">' + config.i18n.toggleFullscreen + '</span>',
|
||||
'</button>'
|
||||
);
|
||||
/* beautify ignore:end */
|
||||
}
|
||||
|
||||
// Close everything
|
||||
@ -1325,12 +1379,15 @@
|
||||
}
|
||||
return _subTcSecs(tcpair[pos]);
|
||||
}
|
||||
|
||||
function _timecodeMin(tc) {
|
||||
return _timecodeCommon(tc, 0);
|
||||
}
|
||||
|
||||
function _timecodeMax(tc) {
|
||||
return _timecodeCommon(tc, 1);
|
||||
}
|
||||
|
||||
function _subTcSecs(tc) {
|
||||
if (tc === null || tc === undefined) {
|
||||
return 0;
|
||||
@ -1424,8 +1481,7 @@
|
||||
function _inFrame() {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1458,7 +1514,9 @@
|
||||
// Add elements to HTML5 media (source, tracks, etc)
|
||||
function _insertChildElements(type, attributes) {
|
||||
if (_is.string(attributes)) {
|
||||
_insertElement(type, plyr.media, { src: attributes });
|
||||
_insertElement(type, plyr.media, {
|
||||
src: attributes
|
||||
});
|
||||
} else if (attributes.constructor === Array) {
|
||||
for (var i = attributes.length - 1; i >= 0; i--) {
|
||||
_insertElement(type, plyr.media, attributes[i]);
|
||||
@ -1588,8 +1646,7 @@
|
||||
plyr.seekTime = _getElements(config.selectors.seekTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(e) {
|
||||
} catch (e) {
|
||||
_warn('It looks like there is a problem with your controls HTML', e);
|
||||
|
||||
// Restore native video controls
|
||||
@ -1664,7 +1721,9 @@
|
||||
// If value is a number, it's probably volume from an older
|
||||
// version of plyr. See: https://github.com/Selz/plyr/pull/313
|
||||
// Update the key to be JSON
|
||||
_updateStorage({volume: parseFloat(value)});
|
||||
_updateStorage({
|
||||
volume: parseFloat(value)
|
||||
});
|
||||
} else {
|
||||
// Assume it's JSON from this or a later version of plyr
|
||||
plyr.storage = JSON.parse(value);
|
||||
@ -1710,7 +1769,7 @@
|
||||
_toggleClass(plyr.container, config.classes.stopped, config.autoplay);
|
||||
|
||||
// Add iOS class
|
||||
_toggleClass(plyr.ontainer, config.classes.isIos, plyr.browser.isIos);
|
||||
_toggleClass(plyr.container, config.classes.isIos, plyr.browser.isIos);
|
||||
|
||||
// Add touch class
|
||||
_toggleClass(plyr.container, config.classes.isTouch, plyr.browser.isTouch);
|
||||
@ -1783,11 +1842,15 @@
|
||||
window.onYouTubeReadyCallbacks = window.onYouTubeReadyCallbacks || [];
|
||||
|
||||
// Add to queue
|
||||
window.onYouTubeReadyCallbacks.push(function() { _youTubeReady(mediaId, container); });
|
||||
window.onYouTubeReadyCallbacks.push(function() {
|
||||
_youTubeReady(mediaId, container);
|
||||
});
|
||||
|
||||
// Set callback to process queue
|
||||
window.onYouTubeIframeAPIReady = function() {
|
||||
window.onYouTubeReadyCallbacks.forEach(function(callback) { callback(); });
|
||||
window.onYouTubeReadyCallbacks.forEach(function(callback) {
|
||||
callback();
|
||||
});
|
||||
};
|
||||
}
|
||||
} else if (plyr.type === 'vimeo') {
|
||||
@ -1822,7 +1885,9 @@
|
||||
|
||||
// Watch for iframe load
|
||||
soundCloud.loaded = false;
|
||||
_on(soundCloud, 'load', function() { soundCloud.loaded = true; });
|
||||
_on(soundCloud, 'load', function() {
|
||||
soundCloud.loaded = true;
|
||||
});
|
||||
|
||||
_setAttributes(soundCloud, {
|
||||
'src': 'https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/' + mediaId,
|
||||
@ -2280,7 +2345,9 @@
|
||||
plyr.media.playbackRate = speed;
|
||||
|
||||
// Save speed to localStorage
|
||||
_updateStorage({speed: speed});
|
||||
_updateStorage({
|
||||
speed: speed
|
||||
});
|
||||
}
|
||||
|
||||
// Seek to time
|
||||
@ -2312,8 +2379,7 @@
|
||||
// Try/catch incase the media isn't set and we're calling seek() from source() and IE moans
|
||||
try {
|
||||
plyr.media.currentTime = targetTime.toFixed(4);
|
||||
}
|
||||
catch(e) {}
|
||||
} catch (e) {}
|
||||
|
||||
// Embeds
|
||||
if (_inArray(config.types.embed, plyr.type)) {
|
||||
@ -2579,7 +2645,9 @@
|
||||
}
|
||||
|
||||
// Update the volume in storage
|
||||
_updateStorage({volume: volume});
|
||||
_updateStorage({
|
||||
volume: volume
|
||||
});
|
||||
|
||||
// Toggle class if muted
|
||||
_toggleClass(plyr.container, config.classes.muted, (volume === 0));
|
||||
@ -2615,7 +2683,9 @@
|
||||
_triggerEvent(plyr.container, plyr.captionsEnabled ? 'captionsenabled' : 'captionsdisabled', true);
|
||||
|
||||
// Save captions state to localStorage
|
||||
_updateStorage({captionsEnabled: plyr.captionsEnabled});
|
||||
_updateStorage({
|
||||
captionsEnabled: plyr.captionsEnabled
|
||||
});
|
||||
}
|
||||
|
||||
// Select active caption
|
||||
@ -3277,24 +3347,50 @@
|
||||
case 54:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57: if (!held) { seekByKey(); } break;
|
||||
case 57:
|
||||
if (!held) {
|
||||
seekByKey();
|
||||
}
|
||||
break;
|
||||
// Space and K key
|
||||
case 32:
|
||||
case 75: if (!held) { _togglePlay(); } break;
|
||||
case 75:
|
||||
if (!held) {
|
||||
_togglePlay();
|
||||
}
|
||||
break;
|
||||
// Arrow up
|
||||
case 38: _increaseVolume(); break;
|
||||
case 38:
|
||||
_increaseVolume();
|
||||
break;
|
||||
// Arrow down
|
||||
case 40: _decreaseVolume(); break;
|
||||
case 40:
|
||||
_decreaseVolume();
|
||||
break;
|
||||
// M key
|
||||
case 77: if (!held) { _toggleMute() } break;
|
||||
case 77:
|
||||
if (!held) {
|
||||
_toggleMute()
|
||||
}
|
||||
break;
|
||||
// Arrow forward
|
||||
case 39: _forward(); break;
|
||||
case 39:
|
||||
_forward();
|
||||
break;
|
||||
// Arrow back
|
||||
case 37: _rewind(); break;
|
||||
case 37:
|
||||
_rewind();
|
||||
break;
|
||||
// F key
|
||||
case 70: _toggleFullscreen(); break;
|
||||
case 70:
|
||||
_toggleFullscreen();
|
||||
break;
|
||||
// C key
|
||||
case 67: if (!held) { _toggleCaptions(); } break;
|
||||
case 67:
|
||||
if (!held) {
|
||||
_toggleCaptions();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Escape is handle natively when in full screen
|
||||
@ -3561,7 +3657,9 @@
|
||||
|
||||
// Disable right click
|
||||
if (config.disableContextMenu) {
|
||||
_on(plyr.media, 'contextmenu', function(event) { event.preventDefault(); });
|
||||
_on(plyr.media, 'contextmenu', function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
// Proxy events to container
|
||||
@ -3811,22 +3909,50 @@
|
||||
}
|
||||
|
||||
api = {
|
||||
getOriginal: function() { return original; },
|
||||
getContainer: function() { return plyr.container },
|
||||
getEmbed: function() { return plyr.embed; },
|
||||
getMedia: function() { return plyr.media; },
|
||||
getType: function() { return plyr.type; },
|
||||
getOriginal: function() {
|
||||
return original;
|
||||
},
|
||||
getContainer: function() {
|
||||
return plyr.container
|
||||
},
|
||||
getEmbed: function() {
|
||||
return plyr.embed;
|
||||
},
|
||||
getMedia: function() {
|
||||
return plyr.media;
|
||||
},
|
||||
getType: function() {
|
||||
return plyr.type;
|
||||
},
|
||||
getDuration: _getDuration,
|
||||
getCurrentTime: function() { return plyr.media.currentTime; },
|
||||
getVolume: function() { return plyr.media.volume; },
|
||||
isMuted: function() { return plyr.media.muted; },
|
||||
isReady: function() { return _hasClass(plyr.container, config.classes.ready); },
|
||||
isLoading: function() { return _hasClass(plyr.container, config.classes.loading); },
|
||||
isPaused: function() { return plyr.media.paused; },
|
||||
on: function(event, callback) { _on(plyr.container, event, callback); return this; },
|
||||
getCurrentTime: function() {
|
||||
return plyr.media.currentTime;
|
||||
},
|
||||
getVolume: function() {
|
||||
return plyr.media.volume;
|
||||
},
|
||||
isMuted: function() {
|
||||
return plyr.media.muted;
|
||||
},
|
||||
isReady: function() {
|
||||
return _hasClass(plyr.container, config.classes.ready);
|
||||
},
|
||||
isLoading: function() {
|
||||
return _hasClass(plyr.container, config.classes.loading);
|
||||
},
|
||||
isPaused: function() {
|
||||
return plyr.media.paused;
|
||||
},
|
||||
on: function(event, callback) {
|
||||
_on(plyr.container, event, callback);
|
||||
return this;
|
||||
},
|
||||
play: _play,
|
||||
pause: _pause,
|
||||
stop: function() { _pause(); _seek(); },
|
||||
stop: function() {
|
||||
_pause();
|
||||
_seek();
|
||||
},
|
||||
restart: _seek,
|
||||
rewind: _rewind,
|
||||
forward: _forward,
|
||||
@ -3841,8 +3967,12 @@
|
||||
toggleFullscreen: _toggleFullscreen,
|
||||
toggleControls: _toggleControls,
|
||||
setCaptionIndex: _setCaptionIndex,
|
||||
isFullscreen: function() { return plyr.isFullscreen || false; },
|
||||
support: function(mimeType) { return _support.mime(plyr, mimeType); },
|
||||
isFullscreen: function() {
|
||||
return plyr.isFullscreen || false;
|
||||
},
|
||||
support: function(mimeType) {
|
||||
return _support.mime(plyr, mimeType);
|
||||
},
|
||||
destroy: _destroy
|
||||
};
|
||||
|
||||
@ -4034,8 +4164,9 @@
|
||||
var data = {};
|
||||
|
||||
// Try parsing data attribute config
|
||||
try { data = JSON.parse(element.getAttribute('data-plyr')); }
|
||||
catch(e) { }
|
||||
try {
|
||||
data = JSON.parse(element.getAttribute('data-plyr'));
|
||||
} catch (e) {}
|
||||
|
||||
var config = _extend({}, defaults, options, data);
|
||||
|
||||
@ -4116,7 +4247,11 @@
|
||||
}
|
||||
|
||||
function CustomEvent(event, params) {
|
||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||
params = params || {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
detail: undefined
|
||||
};
|
||||
var evt = document.createEvent('CustomEvent');
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user