From 84b81e440ddcac969dbdabe14ab523a10d03a577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgardo=20Ram=C3=ADrez?= Date: Tue, 6 Oct 2020 14:53:08 -0500 Subject: [PATCH] ADD: Save volume settings in localstorage --- webroot/js/components/player.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webroot/js/components/player.js b/webroot/js/components/player.js index ca33bffb5..309c154db 100644 --- a/webroot/js/components/player.js +++ b/webroot/js/components/player.js @@ -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 { 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 { 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 { } } + handleVolume(e) { + localStorage.setItem('owncastVolume', this.vjsPlayer.volume()); + } + handlePlaying() { this.log('on Playing'); if (this.appPlayerPlayingCallback) {