diff options
author | Sam Potts <sam@potts.es> | 2020-02-08 23:09:41 +0000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2020-02-08 23:09:41 +0000 |
commit | 90dc985657190f08e91686cdcf404a106c498511 (patch) | |
tree | 73064da9477bebc36413b850e2b9ac77b5cf1dc5 /src/js/controls.js | |
parent | b5456e1de747b40b82a80a724f6724ba438ab24d (diff) | |
download | plyr-90dc985657190f08e91686cdcf404a106c498511.tar.lz plyr-90dc985657190f08e91686cdcf404a106c498511.tar.xz plyr-90dc985657190f08e91686cdcf404a106c498511.zip |
Clean up speed options logic
Diffstat (limited to 'src/js/controls.js')
-rw-r--r-- | src/js/controls.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/js/controls.js b/src/js/controls.js index 0b66d8f6..f93cb8a3 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -9,7 +9,7 @@ import captions from './captions'; import html5 from './html5'; import support from './support'; import { repaint, transitionEndEvent } from './utils/animation'; -import { dedupe } from './utils/arrays'; +import { dedupe, fillRange } from './utils/arrays'; import browser from './utils/browser'; import { createElement, @@ -1044,7 +1044,7 @@ const controls = { }, // Set a list of available captions languages - setSpeedMenu(options) { + setSpeedMenu() { // Menu required if (!is.element(this.elements.settings.panels.speed)) { return; @@ -1053,18 +1053,14 @@ const controls = { const type = 'speed'; const list = this.elements.settings.panels.speed.querySelector('[role="menu"]'); - // Set the speed options - if (is.array(options)) { - this.options.speed = options; - } else if (is.array(this.config.speed.options)) { + // Determine options to display + // Vimeo and YouTube limit to 0.5x-2x + if (this.isVimeo || this.isYouTube) { + this.options.speed = fillRange(0.5, 2, 0.25).filter(s => this.config.speed.options.includes(s)); + } else { this.options.speed = this.config.speed.options; - } else if (this.isHTML5 || this.isVimeo) { - this.options.speed = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]; } - // Set options if passed and filter based on config - this.options.speed = this.options.speed.filter(speed => this.config.speed.options.includes(speed)); - // Toggle the pane and tab const toggle = !is.empty(this.options.speed) && this.options.speed.length > 1; controls.toggleMenuButton.call(this, type, toggle); |