diff options
author | Sam Potts <sam@potts.es> | 2018-09-28 00:42:42 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-09-28 00:42:42 +1000 |
commit | fac134dd955fe1a264a68897cd49d06a5afd9750 (patch) | |
tree | 50bb1e10b0033d4d0c3ac68fb236a4412b17a5e1 /src/js/listeners.js | |
parent | 515ae32160c8317cfddff07362d9aa399452d05d (diff) | |
download | plyr-fac134dd955fe1a264a68897cd49d06a5afd9750.tar.lz plyr-fac134dd955fe1a264a68897cd49d06a5afd9750.tar.xz plyr-fac134dd955fe1a264a68897cd49d06a5afd9750.zip |
Added download button
Diffstat (limited to 'src/js/listeners.js')
-rw-r--r-- | src/js/listeners.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/js/listeners.js b/src/js/listeners.js index f938d9a2..31d74af6 100644 --- a/src/js/listeners.js +++ b/src/js/listeners.js @@ -431,6 +431,11 @@ class Listeners { controls.updateSetting.call(player, 'quality', null, event.detail.quality); }); + // Update download link + on.call(player, player.media, 'ready qualitychange', () => { + controls.setDownloadLink.call(player); + }); + // Proxy events to container // Bubble up key events for Edge const proxyEvents = player.config.events.concat(['keyup', 'keydown']).join(' '); @@ -517,6 +522,16 @@ class Listeners { // Captions toggle this.bind(elements.buttons.captions, 'click', () => player.toggleCaptions()); + // Download + this.bind( + elements.buttons.download, + 'click', + () => { + triggerEvent.call(player, player.media, 'download'); + }, + 'download', + ); + // Fullscreen toggle this.bind( elements.buttons.fullscreen, @@ -698,7 +713,7 @@ class Listeners { }); // Show controls when they receive focus (e.g., when using keyboard tab key) - this.bind(elements.controls, 'focusin', event => { + this.bind(elements.controls, 'focusin', () => { const { config, elements, timers } = player; // Skip transition to prevent focus from scrolling the parent element @@ -712,7 +727,7 @@ class Listeners { toggleClass(elements.controls, config.classNames.noTransition, false); }, 0); - // Delay a little more for keyboard users + // Delay a little more for mouse users const delay = this.touch ? 3000 : 4000; // Clear timer |