88 lines
2.3 KiB
JavaScript
88 lines
2.3 KiB
JavaScript
|
/*
|
||
|
* @copyright Copyright (c) 2021 Jonas Heinrich <onny@project-insanity.org>
|
||
|
*
|
||
|
* @author Jonas Heinrich <onny@project-insanity.org>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
export default ({
|
||
|
state: {
|
||
|
isPlaying: false,
|
||
|
isBuffering: false,
|
||
|
isMute: false,
|
||
|
isPaused: false,
|
||
|
volume: localStorage.getItem('radio.volume') || 0.5,
|
||
|
oldVolume: localStorage.getItem('radio.volume') || 0.5,
|
||
|
title: '',
|
||
|
},
|
||
|
mutations: {
|
||
|
setPlaying(state, playerState) {
|
||
|
state.isPlaying = playerState
|
||
|
},
|
||
|
setBuffering(state, bufferingState) {
|
||
|
state.isBuffering = bufferingState
|
||
|
},
|
||
|
setVolume(state, volume) {
|
||
|
state.volume = volume
|
||
|
localStorage.setItem('radio.volume', volume)
|
||
|
},
|
||
|
toggleMute(state) {
|
||
|
if (state.isMute) {
|
||
|
state.volume = state.player.oldVolume
|
||
|
state.isMute = false
|
||
|
} else {
|
||
|
state.oldVolume = state.player.volume
|
||
|
state.volume = 0
|
||
|
state.isMute = true
|
||
|
}
|
||
|
},
|
||
|
togglePlay(state) {
|
||
|
if (state.isPlaying) {
|
||
|
state.isPlaying = false
|
||
|
state.isPaused = true
|
||
|
} else {
|
||
|
state.isPlaying = true
|
||
|
state.isPaused = false
|
||
|
}
|
||
|
},
|
||
|
setTitle(state, title) {
|
||
|
state.title = title
|
||
|
},
|
||
|
},
|
||
|
actions: {
|
||
|
setPlaying(context, playerState) {
|
||
|
context.commit('setPlaying', playerState)
|
||
|
},
|
||
|
setBuffering(context, bufferingState) {
|
||
|
context.commit('setBuffering', bufferingState)
|
||
|
},
|
||
|
setVolume(context, volume) {
|
||
|
context.commit('setVolume', volume)
|
||
|
},
|
||
|
toggleMute(context) {
|
||
|
context.commit('toggleMute')
|
||
|
},
|
||
|
togglePlay(context) {
|
||
|
context.commit('togglePlay')
|
||
|
},
|
||
|
setTitle(context, title) {
|
||
|
context.commit('setTitle', title)
|
||
|
},
|
||
|
},
|
||
|
})
|