Small improvements, docs updated

This commit is contained in:
Sam Potts 2015-02-28 11:18:24 +11:00
parent f8b4622093
commit dd17100a53
3 changed files with 26 additions and 13 deletions

2
dist/js/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -193,7 +193,13 @@ You can pass the following settings:
<td><code>fullscreen</code></td> <td><code>fullscreen</code></td>
<td>Object</td> <td>Object</td>
<td>&mdash;</td> <td>&mdash;</td>
<td>This currently contains one property `enabled` which toggles if fullscreen should be enabled (if the browser supports it). The default value is `true`.</td> <td>This currently contains two properties; `enabled` which toggles if fullscreen should be enabled (if the browser supports it). The default value is `true`. Also an extra property called `fallback` which will enable a 'full window' view for older browsers. The default value is `true`.</td>
</tr>
<tr>
<td><code>storage</code></td>
<td>Object</td>
<td>&mdash;</td>
<td>This currently contains one property `enabled` which toggles if local storage should be enabled (if the browser supports it). The default value is `true`. This enables storing user settings, currently it only stores volume but more will be added later.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -66,15 +66,7 @@
fallback: true fallback: true
}, },
storage: { storage: {
enabled: true, enabled: true
supported: function() {
try {
return "localStorage" in window && window.localStorage !== null;
}
catch(e) {
return false;
}
}
} }
}; };
@ -342,6 +334,21 @@
return fullscreen; return fullscreen;
} }
// Local storage
function _storage() {
var storage = {
supported: (function() {
try {
return "localStorage" in window && window.localStorage !== null;
}
catch(e) {
return false;
}
})()
}
return storage;
}
// Player instance // Player instance
function Plyr(container) { function Plyr(container) {
var player = this; var player = this;
@ -829,7 +836,7 @@
function _setVolume(volume) { function _setVolume(volume) {
// Use default if needed // Use default if needed
if(typeof volume === "undefined") { if(typeof volume === "undefined") {
if(config.storage.enabled && config.storage.supported) { if(config.storage.enabled && _storage().supported) {
volume = window.localStorage.plyr_volume || config.volume; volume = window.localStorage.plyr_volume || config.volume;
} }
else { else {
@ -846,7 +853,7 @@
_checkMute(); _checkMute();
// Store the volume in storage // Store the volume in storage
if(config.storage.enabled && config.storage.supported) { if(config.storage.enabled && _storage().supported) {
window.localStorage.plyr_volume = volume; window.localStorage.plyr_volume = volume;
} }
} }