Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

fixes not updating on volume slider and mute on vjs6 #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions videojs.persistvolume.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
(function(factory){
(function(factory) {
/*!
* Custom Universal Module Definition (UMD)
*
Expand All @@ -8,7 +8,7 @@
* compiler compatible, so string keys are used.
*/
if (typeof define === 'function' && define['amd']) {
define(['./video'], function(vjs){ factory(window, document, vjs) });
define(['video.js'], function(vjs){ factory(window, document, vjs) });
// checking that module is an object too because of umdjs/umd#35
} else if (typeof exports === 'object' && typeof module === 'object') {
factory(window, document, require('video.js'));
Expand Down Expand Up @@ -101,23 +101,25 @@

var key = settings.namespace + '-' + 'volume';
var muteKey = settings.namespace + '-' + 'mute';

player.on("volumechange", function() {
setStorageItem(key, player.volume());
setStorageItem(muteKey, player.muted());
});

var persistedVolume = getStorageItem(key);
if(persistedVolume !== null){
player.volume(persistedVolume);
}
player.ready(function() {
var persistedMute = getStorageItem(muteKey);
if(persistedMute !== null) {
player.muted('true' === persistedMute);
}

var persistedMute = getStorageItem(muteKey);
if(persistedMute !== null){
player.muted('true' === persistedMute);
}
var persistedVolume = getStorageItem(key);
if(persistedVolume !== null) {
player.volume(persistedVolume);
player.trigger('volumechange');
}
});
};

vjs.plugin("persistvolume", volumePersister);
vjs.registerPlugin("persistvolume", volumePersister);

});
});