nextcloud-app-radio/src/store.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-10-23 15:49:24 +00:00
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
2020-10-23 20:18:05 +00:00
state: {
player: {
isPlaying: false,
isBuffering: false,
volume: 0,
2020-10-25 09:51:08 +00:00
isMute: false,
oldVolume: 0,
2020-10-23 20:18:05 +00:00
},
2020-10-23 15:49:24 +00:00
},
mutations: {
2020-10-23 20:18:05 +00:00
isPlaying(state, playerState) {
state.player.isPlaying = playerState
},
isBuffering(state, bufferingState) {
state.player.isBuffering = bufferingState
},
2020-10-25 09:23:31 +00:00
changeVolume(state, volume) {
state.player.volume = volume
},
2020-10-25 09:51:08 +00:00
toggleMute(state) {
if (state.player.isMute) {
state.player.volume = state.player.oldVolume
} else {
state.player.oldVolume = state.player.volume
state.player.volume = 0
}
},
2020-10-26 14:51:22 +00:00
togglePlay(state) {
console.log('toggle play')
if (state.player.isPlaying) {
state.player.isPlaying = false
} else {
state.player.isPlaying = true
}
},
2020-10-23 20:18:05 +00:00
},
actions: {
isPlaying(context, playerState) {
context.commit('isPlaying', playerState)
},
isBuffering(context, bufferingState) {
context.commit('isBuffering', bufferingState)
2020-10-23 15:49:24 +00:00
},
2020-10-25 09:23:31 +00:00
changeVolume(context, volume) {
context.commit('changeVolume', volume)
},
2020-10-25 09:51:08 +00:00
toggleMute(context) {
2020-10-26 14:51:22 +00:00
context.commit('toggleMute')
},
togglePlay(context) {
context.commit('togglePlay')
2020-10-25 09:51:08 +00:00
},
2020-10-23 15:49:24 +00:00
},
})