From 0afb670d167205658d5d5f2ea6b2540eab3c0d74 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 26 Oct 2020 16:21:31 +0100 Subject: [PATCH] implement play/pause --- src/components/Main.vue | 7 +++++++ src/store.js | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/Main.vue b/src/components/Main.vue index e63a7a6..2c0ed43 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -65,6 +65,13 @@ export default { audioPlayer.volume(newVolume) } }, + 'player.isPaused'(newState, oldState) { + if (newState === true && audioPlayer !== null) { + audioPlayer.pause() + } else if (newState === false && audioPlayer !== null) { + audioPlayer.play() + } + }, }, mounted() { this.loadStations() diff --git a/src/store.js b/src/store.js index b48d1c9..d3cdf20 100644 --- a/src/store.js +++ b/src/store.js @@ -7,8 +7,9 @@ export default new Vuex.Store({ player: { isPlaying: false, isBuffering: false, - volume: 0, isMute: false, + isPaused: false, + volume: 0, oldVolume: 0, }, }, @@ -33,11 +34,12 @@ export default new Vuex.Store({ } }, togglePlay(state) { - console.log('toggle play') if (state.player.isPlaying) { state.player.isPlaying = false + state.player.isPaused = true } else { state.player.isPlaying = true + state.player.isPaused = false } }, },