Set download URL via setter
This commit is contained in:
6
src/js/controls.js
vendored
6
src/js/controls.js
vendored
@ -1244,8 +1244,8 @@ const controls = {
|
|||||||
controls.focusFirstMenuItem.call(this, target, tabFocus);
|
controls.focusFirstMenuItem.call(this, target, tabFocus);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set the download link
|
// Set the download URL
|
||||||
setDownloadLink() {
|
setDownloadUrl() {
|
||||||
const button = this.elements.buttons.download;
|
const button = this.elements.buttons.download;
|
||||||
|
|
||||||
// Bail if no button
|
// Bail if no button
|
||||||
@ -1253,7 +1253,7 @@ const controls = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set download link
|
// Set attribute
|
||||||
button.setAttribute('href', this.download);
|
button.setAttribute('href', this.download);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ class Listeners {
|
|||||||
|
|
||||||
// Update download link when ready and if quality changes
|
// Update download link when ready and if quality changes
|
||||||
on.call(player, player.media, 'ready qualitychange', () => {
|
on.call(player, player.media, 'ready qualitychange', () => {
|
||||||
controls.setDownloadLink.call(player);
|
controls.setDownloadUrl.call(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Proxy events to container
|
// Proxy events to container
|
||||||
|
@ -48,14 +48,14 @@ const vimeo = {
|
|||||||
// Set intial ratio
|
// Set intial ratio
|
||||||
setAspectRatio.call(this);
|
setAspectRatio.call(this);
|
||||||
|
|
||||||
// Load the API if not already
|
// Load the SDK if not already
|
||||||
if (!is.object(window.Vimeo)) {
|
if (!is.object(window.Vimeo)) {
|
||||||
loadScript(this.config.urls.vimeo.sdk)
|
loadScript(this.config.urls.vimeo.sdk)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
vimeo.ready.call(this);
|
vimeo.ready.call(this);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.debug.warn('Vimeo API failed to load', error);
|
this.debug.warn('Vimeo SDK (player.js) failed to load', error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
vimeo.ready.call(this);
|
vimeo.ready.call(this);
|
||||||
@ -259,7 +259,7 @@ const vimeo = {
|
|||||||
.getVideoUrl()
|
.getVideoUrl()
|
||||||
.then(value => {
|
.then(value => {
|
||||||
currentSrc = value;
|
currentSrc = value;
|
||||||
controls.setDownloadLink.call(player);
|
controls.setDownloadUrl.call(player);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.debug.warn(error);
|
this.debug.warn(error);
|
||||||
|
@ -823,6 +823,19 @@ class Plyr {
|
|||||||
return is.url(download) ? download : this.source;
|
return is.url(download) ? download : this.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the download URL
|
||||||
|
*/
|
||||||
|
set download(input) {
|
||||||
|
if (!is.url(input)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.config.urls.download = input;
|
||||||
|
|
||||||
|
controls.setDownloadUrl.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the poster image for a video
|
* Set the poster image for a video
|
||||||
* @param {String} input - the URL for the new poster image
|
* @param {String} input - the URL for the new poster image
|
||||||
|
Reference in New Issue
Block a user