Improved player

This commit is contained in:
Thomas
2020-07-31 15:09:37 +02:00
parent c577d8f360
commit 76c6b45e2b
5 changed files with 120 additions and 33 deletions

View File

@@ -35,6 +35,9 @@ const actions = {
setAdmin ({ commit }) {
commit('SET_ADMIN')
},
setTimeCode ({ commit }, timeCode) {
commit('SET_TIMECODE', timeCode)
},
vote ({ commit, dispatch, state }, { link, linkID, isPositive, voterName }) {
console.log('vote on ' + link + ' | ' + linkID + ' (' + isPositive + ') by ' + voterName)
if (isPositive) {
@@ -51,7 +54,7 @@ const actions = {
}
dispatch('rtc/broadcast', { message: state.roomStatus, type: 'status' }, { root: true })
},
setCurrent ({ commit, dispatch }, { playerStatus, timeCode, title }) {
setCurrent ({ commit, dispatch }, { playerStatus, timeCode, timeLength, title }) {
switch (playerStatus) {
case 0:
commit('CURRENT_END')
@@ -59,12 +62,33 @@ const actions = {
case 1:
commit('CURRENT_PLAY', timeCode)
commit('SET_CURRENTTITLE', title)
commit('SET_TIMELENGTH', timeLength)
break
case 2:
commit('CURRENT_PAUSE', timeCode)
break
}
dispatch('rtc/broadcast', { message: state.roomStatus, type: 'status' }, { root: true })
},
leave ({ commit, dispatch }) {
dispatch('rtc/leave', null, { root: true })
commit('SET_ROOMSTATUS', {
roomName: '',
roomCode: '',
player: {
timeCode: 0,
timeLength: 0,
playing: true
},
current: {
link: '',
linkID: '',
title: '',
votes: 0,
voters: []
},
playlist: []
})
}
}
@@ -81,6 +105,12 @@ const mutations = {
SET_ADMIN (state) {
state.admin = true
},
SET_TIMECODE (state, timeCode) {
state.roomStatus.player.timeCode = timeCode
},
SET_TIMELENGTH (state, timeLength) {
state.roomStatus.player.timeLength = timeLength
},
SET_CURRENTTITLE (state, title) {
state.roomStatus.current.title = title
},