aboutsummaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
authorSam Potts <me@sampotts.me>2015-02-17 15:18:07 +1100
committerSam Potts <me@sampotts.me>2015-02-17 15:18:07 +1100
commite86cda5b83327697309d04dc68c6dc6e9e22023b (patch)
tree756eaeb87f55b737bf43964fab646d81b1b81739 /assets/js
parenta39bbec1fd2826f3373b8e3f8260e86f8eedf522 (diff)
downloadplyr-e86cda5b83327697309d04dc68c6dc6e9e22023b.tar.lz
plyr-e86cda5b83327697309d04dc68c6dc6e9e22023b.tar.xz
plyr-e86cda5b83327697309d04dc68c6dc6e9e22023b.zip
Ability to pass values to forward() and rewind()
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/plyr.js35
1 files changed, 29 insertions, 6 deletions
diff --git a/assets/js/plyr.js b/assets/js/plyr.js
index c1049210..7309f422 100644
--- a/assets/js/plyr.js
+++ b/assets/js/plyr.js
@@ -665,8 +665,13 @@
}
// Rewind
- function _rewind() {
- var targetTime = player.media.currentTime - config.seekInterval;
+ function _rewind(seekInterval) {
+ // Use default if needed
+ if(typeof seekInterval === "undefined") {
+ seekInterval = config.seekInterval;
+ }
+
+ var targetTime = player.media.currentTime - seekInterval;
if (targetTime < 0) {
player.media.currentTime = 0;
@@ -681,8 +686,13 @@
}
// Fast forward
- function _forward() {
- var targetTime = player.media.currentTime + config.seekInterval;
+ function _forward(seekInterval) {
+ // Use default if needed
+ if(typeof seekInterval === "undefined") {
+ seekInterval = config.seekInterval;
+ }
+
+ var targetTime = player.media.currentTime + seekInterval;
if (targetTime > player.media.duration) {
player.media.currentTime = player.media.duration;
@@ -708,6 +718,15 @@
// Set volume
function _setVolume(volume) {
+ // Use default if needed
+ if(typeof volume === "undefined") {
+ volume = config.volume;
+ }
+ // Maximum is 10
+ if(volume > 10) {
+ volume = 10;
+ }
+
player.volume.value = volume;
player.media.volume = parseFloat(volume / 10);
_checkMute();
@@ -782,10 +801,14 @@
_on(player.buttons.restart, "click", _restart);
// Rewind
- _on(player.buttons.rewind, "click", _rewind);
+ _on(player.buttons.rewind, "click", function() {
+ _rewind(config.seekInterval);
+ });
// Fast forward
- _on(player.buttons.forward, "click", _forward);
+ _on(player.buttons.forward, "click", function() {
+ _forward(config.seekInterval);
+ });
// Get the HTML5 range input element and append audio volume adjustment on change
_on(player.volume, "change", function() {