From cf166f7f0126bbeb4fa13ba9b9d5adee2f65df4b Mon Sep 17 00:00:00 2001 From: Paul Sori Date: Sat, 18 Aug 2018 03:10:53 -0400 Subject: [PATCH] Store volume in cookies --- public/js/mstream.vue-player-controls.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/js/mstream.vue-player-controls.js b/public/js/mstream.vue-player-controls.js index 4970680..d14b83a 100644 --- a/public/js/mstream.vue-player-controls.js +++ b/public/js/mstream.vue-player-controls.js @@ -127,8 +127,6 @@ var VUEPLAYER = function () { jukeStats = JUKEBOX.stats } - - // TODO: Get volume from cookies new Vue({ el: '#mstream-player', data: { @@ -141,6 +139,12 @@ var VUEPLAYER = function () { lastVol: 100, isViz: false }, + created: function () { + if(Cookies && Cookies.get('volume')) { + this.curVol = Cookies.get('volume'); + MSTREAMPLAYER.changeVolume(parseInt(this.curVol)); + } + }, watch: { curVol: function () { // TODO: Convert to log scale before sening to mstream @@ -156,6 +160,10 @@ var VUEPLAYER = function () { // var scale = (maxv-minv) / (maxp-minp); // // var solution = Math.exp(minv + scale*(this.curVol-minp)) + if (Cookies) { + Cookies.set('volume', parseInt(this.curVol)); + } + MSTREAMPLAYER.changeVolume(parseInt(this.curVol)); } },