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