diff options
author | Sam Potts <sam@potts.es> | 2017-11-08 00:37:14 +1100 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2017-11-08 00:37:14 +1100 |
commit | c948e95adea876c7c43785fe904bedd22f9c307d (patch) | |
tree | 7b134748e4dd4784becf25037344c6cb4ab608e6 /src/js/plyr.js | |
parent | 1a5f4b1b9e1b2b8b316997c4be33d9af240e1383 (diff) | |
download | plyr-c948e95adea876c7c43785fe904bedd22f9c307d.tar.lz plyr-c948e95adea876c7c43785fe904bedd22f9c307d.tar.xz plyr-c948e95adea876c7c43785fe904bedd22f9c307d.zip |
Looping, increase/decrease volume fix
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 09b2aa8a..16a3a2e0 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -1,4 +1,4 @@ -// ========================================================================== +// ========================================================================== // Plyr // plyr.js v3.0.0 // https://github.com/sampotts/plyr @@ -419,16 +419,16 @@ class Plyr { // Increase volume increaseVolume(step) { - const volume = this.media.muted ? 0 : this.media.volume; - - return this.setVolume(volume + utils.is.number(step) ? step : 1); + const volume = this.media.muted ? 0 : this.volume; + this.volume = volume + utils.is.number(step) ? step : 1; + return this; } // Decrease volume decreaseVolume(step) { - const volume = this.media.muted ? 0 : this.media.volume; - - return this.setVolume(volume - utils.is.number(step) ? step : 1); + const volume = this.media.muted ? 0 : this.volume; + this.volume = volume - utils.is.number(step) ? step : 1; + return this; } // Toggle mute @@ -517,11 +517,14 @@ class Plyr { } // Toggle loop - // TODO: Finish logic - // TODO: Set the indicator on load as user may pass loop as config - /* loop(input) { + // TODO: Finish fancy new logic. Set the indicator on load as user may pass loop as config + set loop(input) { + const toggle = utils.is.boolean(input) ? input : this.config.loop.active; + this.config.loop.active = toggle; + this.media.loop = toggle; + // Set default to be a true toggle - const type = ['start', 'end', 'all', 'none', 'toggle'].includes(input) ? input : 'toggle'; + /* const type = ['start', 'end', 'all', 'none', 'toggle'].includes(input) ? input : 'toggle'; switch (type) { case 'start': @@ -561,11 +564,12 @@ class Plyr { this.config.loop.start = 0; this.config.loop.end = null; break; - } + } */ + } - // Allow chaining - return this; - } */ + get loop() { + return this.media.loop; + } // Media source set src(input) { @@ -596,6 +600,15 @@ class Plyr { return this.media.getAttribute('poster'); } + // Autoplay + get autoplay() { + return this.config.autoplay; + } + set autoplay(input) { + const toggle = utils.is.boolean(input) ? input : this.config.autoplay; + this.config.autoplay = toggle; + } + // Toggle captions toggleCaptions(input) { // If there's no full support, or there's no caption toggle |