2020-10-23 15:49:24 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Vuex from 'vuex'
|
2020-10-27 12:43:30 +00:00
|
|
|
|
|
|
|
import axios from '@nextcloud/axios'
|
|
|
|
import { generateUrl } from '@nextcloud/router'
|
|
|
|
|
2020-10-23 15:49:24 +00:00
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
export default new Vuex.Store({
|
2020-10-23 20:18:05 +00:00
|
|
|
state: {
|
|
|
|
player: {
|
|
|
|
isPlaying: false,
|
|
|
|
isBuffering: false,
|
2020-10-25 09:51:08 +00:00
|
|
|
isMute: false,
|
2020-10-26 15:21:31 +00:00
|
|
|
isPaused: false,
|
2020-10-28 20:21:59 +00:00
|
|
|
volume: 0.5,
|
2020-10-25 09:51:08 +00:00
|
|
|
oldVolume: 0,
|
2020-11-12 10:37:30 +00:00
|
|
|
title: '',
|
2020-10-23 20:18:05 +00:00
|
|
|
},
|
2020-10-28 20:21:59 +00:00
|
|
|
menu: 'top',
|
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
|
2020-10-26 15:03:25 +00:00
|
|
|
state.player.isMute = false
|
2020-10-25 09:51:08 +00:00
|
|
|
} else {
|
|
|
|
state.player.oldVolume = state.player.volume
|
|
|
|
state.player.volume = 0
|
2020-10-26 15:03:25 +00:00
|
|
|
state.player.isMute = true
|
2020-10-25 09:51:08 +00:00
|
|
|
}
|
|
|
|
},
|
2020-10-26 14:51:22 +00:00
|
|
|
togglePlay(state) {
|
|
|
|
if (state.player.isPlaying) {
|
|
|
|
state.player.isPlaying = false
|
2020-10-26 15:21:31 +00:00
|
|
|
state.player.isPaused = true
|
2020-10-26 14:51:22 +00:00
|
|
|
} else {
|
|
|
|
state.player.isPlaying = true
|
2020-10-26 15:21:31 +00:00
|
|
|
state.player.isPaused = false
|
2020-10-26 14:51:22 +00:00
|
|
|
}
|
|
|
|
},
|
2020-10-26 15:41:58 +00:00
|
|
|
setTitle(state, title) {
|
|
|
|
state.player.title = title
|
|
|
|
},
|
2020-10-27 12:43:30 +00:00
|
|
|
setMenuState(state, menuState) {
|
|
|
|
axios.post(generateUrl('/apps/radio/settings/menuState'), {
|
|
|
|
menuState,
|
|
|
|
})
|
|
|
|
},
|
2020-10-28 20:21:59 +00:00
|
|
|
getMenuState(state) {
|
2020-10-27 12:43:30 +00:00
|
|
|
axios
|
|
|
|
.get(generateUrl('/apps/radio/settings/menuState'))
|
|
|
|
.then(async response => {
|
|
|
|
const {
|
|
|
|
data: { menuState: value },
|
|
|
|
} = response
|
2020-10-28 20:21:59 +00:00
|
|
|
state.menu = value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
setVolumeState(state, volumeState) {
|
|
|
|
axios.post(generateUrl('/apps/radio/settings/volumeState'), {
|
|
|
|
volumeState,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getVolumeState(state) {
|
|
|
|
axios
|
|
|
|
.get(generateUrl('/apps/radio/settings/volumeState'))
|
|
|
|
.then(async response => {
|
|
|
|
const {
|
|
|
|
data: { volumeState: value },
|
|
|
|
} = response
|
|
|
|
state.player.volume = value
|
2020-10-27 12:43:30 +00:00
|
|
|
})
|
|
|
|
},
|
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-26 15:41:58 +00:00
|
|
|
setTitle(context, title) {
|
|
|
|
context.commit('setTitle', title)
|
|
|
|
},
|
2020-10-27 12:43:30 +00:00
|
|
|
setMenuState(context, menuState) {
|
|
|
|
context.commit('setMenuState', menuState)
|
|
|
|
},
|
|
|
|
getMenuState(context) {
|
|
|
|
context.commit('getMenuState')
|
|
|
|
},
|
2020-10-28 20:21:59 +00:00
|
|
|
setVolumeState(context, volumeState) {
|
|
|
|
context.commit('setVolumeState', volumeState)
|
|
|
|
},
|
|
|
|
getVolumeState(context) {
|
|
|
|
context.commit('getVolumeState')
|
|
|
|
},
|
2020-10-23 15:49:24 +00:00
|
|
|
},
|
|
|
|
})
|