implement play/pause

This commit is contained in:
Jonas Heinrich 2020-10-26 16:21:31 +01:00
parent 9336aa180c
commit 0afb670d16
2 changed files with 11 additions and 2 deletions

View File

@ -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()

View File

@ -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
}
},
},