Browse Source

ADD: Save volume settings in localstorage

pull/228/head
Edgardo Ramírez 5 years ago
parent
commit
84b81e440d
  1. 7
      webroot/js/components/player.js

7
webroot/js/components/player.js

@ -47,6 +47,7 @@ class OwncastPlayer { @@ -47,6 +47,7 @@ class OwncastPlayer {
this.startPlayer = this.startPlayer.bind(this);
this.handleReady = this.handleReady.bind(this);
this.handlePlaying = this.handlePlaying.bind(this);
this.handleVolume = this.handleVolume.bind(this);
this.handleEnded = this.handleEnded.bind(this);
this.handleError = this.handleError.bind(this);
}
@ -76,6 +77,7 @@ class OwncastPlayer { @@ -76,6 +77,7 @@ class OwncastPlayer {
startPlayer() {
this.log('Start playing');
const source = { ...VIDEO_SRC }
this.vjsPlayer.volume(localStorage.getItem('owncastVolume'));
this.vjsPlayer.src(source);
// this.vjsPlayer.play();
};
@ -84,6 +86,7 @@ class OwncastPlayer { @@ -84,6 +86,7 @@ class OwncastPlayer {
this.log('on Ready');
this.vjsPlayer.on('error', this.handleError);
this.vjsPlayer.on('playing', this.handlePlaying);
this.vjsPlayer.on('volumechange', this.handleVolume);
this.vjsPlayer.on('ended', this.handleEnded);
if (this.appPlayerReadyCallback) {
@ -92,6 +95,10 @@ class OwncastPlayer { @@ -92,6 +95,10 @@ class OwncastPlayer {
}
}
handleVolume(e) {
localStorage.setItem('owncastVolume', this.vjsPlayer.volume());
}
handlePlaying() {
this.log('on Playing');
if (this.appPlayerPlayingCallback) {

Loading…
Cancel
Save