Merge branch 'develop' of https://github.com/Selz/plyr into develop
# Conflicts: # dist/plyr.js # dist/plyr.js.map
This commit is contained in:
commit
fd97607e55
@ -25,6 +25,7 @@ const vimeo = {
|
|||||||
// Load the API if not already
|
// Load the API if not already
|
||||||
if (!utils.is.object(window.Vimeo)) {
|
if (!utils.is.object(window.Vimeo)) {
|
||||||
utils.loadScript(this.config.urls.vimeo.api);
|
utils.loadScript(this.config.urls.vimeo.api);
|
||||||
|
|
||||||
// Wait for load
|
// Wait for load
|
||||||
const vimeoTimer = window.setInterval(() => {
|
const vimeoTimer = window.setInterval(() => {
|
||||||
if (utils.is.object(window.Vimeo)) {
|
if (utils.is.object(window.Vimeo)) {
|
||||||
@ -38,6 +39,7 @@ const vimeo = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Set aspect ratio
|
// Set aspect ratio
|
||||||
|
// For Vimeo we have an extra 300% height <div> to hide the standard controls and UI
|
||||||
setAspectRatio(input) {
|
setAspectRatio(input) {
|
||||||
const ratio = utils.is.string(input) ? input.split(':') : this.config.ratio.split(':');
|
const ratio = utils.is.string(input) ? input.split(':') : this.config.ratio.split(':');
|
||||||
const padding = 100 / ratio[0] * ratio[1];
|
const padding = 100 / ratio[0] * ratio[1];
|
||||||
|
@ -76,17 +76,26 @@ const utils = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Load an external script
|
// Load an external script
|
||||||
loadScript(url) {
|
loadScript(url, callback) {
|
||||||
// Check script is not already referenced
|
// Check script is not already referenced
|
||||||
if (document.querySelectorAll(`script[src="${url}"]`).length) {
|
if (document.querySelectorAll(`script[src="${url}"]`).length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tag = document.createElement('script');
|
// Build the element
|
||||||
tag.src = url;
|
const element = document.createElement('script');
|
||||||
|
element.src = url;
|
||||||
|
|
||||||
const firstScriptTag = document.getElementsByTagName('script')[0];
|
// Find first script
|
||||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
const first = document.getElementsByTagName('script')[0];
|
||||||
|
|
||||||
|
// Bind callback
|
||||||
|
if (utils.is.function(callback)) {
|
||||||
|
element.addEventListener('load', event => callback.call(null, event), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inject
|
||||||
|
first.parentNode.insertBefore(element, first);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Load an external SVG sprite
|
// Load an external SVG sprite
|
||||||
|
Loading…
x
Reference in New Issue
Block a user