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

Prefer vjs.registerPlugin over vjs.plugin #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
videojs-persistvolume
========================
# videojs-persistvolume

A plugin for Video.js that saves user's volume setting using [localStorage](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage#localStorage), but falls back to cookies if necessary.

###Usage
### Usage
Include the plugin:

```
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "videojs-persistvolume",
"main": "videojs.persistvolume.js",
"version": "0.1.3p1",
"license": "MIT",
"homepage": "https://github.com/jbboehr/videojs-persistvolume",
"repository": {
"type": "git",
"url": "git://github.com/jbboehr/videojs-persistvolume.git"
}
}
6 changes: 3 additions & 3 deletions test/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<video id="vid1" class="video-js vjs-default-skin" autoplay controls preload="auto"
poster="http://video-js.zencoder.com/oceans-clip.png"
data-setup='{}'>
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4'>
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm'>
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg'>
<source src="http://vjs.zencdn.net/v/oceans.mp4" type='video/mp4'>
<source src="http://vjs.zencdn.net/v/oceans.webm" type='video/webm'>
<source src="http://vjs.zencdn.net/v/oceans.ogv" type='video/ogg'>
<p>Video Playback Not Supported</p>
</video>

Expand Down
26 changes: 14 additions & 12 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 @@ -107,17 +107,19 @@
setStorageItem(muteKey, player.muted());
});

var persistedVolume = getStorageItem(key);
if(persistedVolume !== null){
player.volume(persistedVolume);
}
player.ready(function() {
var persistedVolume = getStorageItem(key);
if(persistedVolume !== null) {
player.volume(persistedVolume);
}

var persistedMute = getStorageItem(muteKey);
if(persistedMute !== null){
player.muted('true' === persistedMute);
}
var persistedMute = getStorageItem(muteKey);
if(persistedMute !== null) {
player.muted('true' === persistedMute);
}
});
};

vjs.plugin("persistvolume", volumePersister);
vjs[ (vjs.registerPlugin ? 'registerPlugin' : 'plugin') ]("persistvolume", volumePersister);

});
});