fix: handle started action
All checks were successful
repod / xml (push) Successful in 23s
repod / php (push) Successful in 1m7s
repod / nodejs (push) Successful in 2m20s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-01-16 22:36:01 +01:00
parent 9ebd96cec1
commit 1d65481be8

View File

@ -25,6 +25,7 @@ export const player = {
paused: null, paused: null,
podcastUrl: null, podcastUrl: null,
volume: 1, volume: 1,
started: 0,
rate: 1, rate: 1,
}, },
mutations: { mutations: {
@ -33,6 +34,7 @@ export const player = {
if (action && action.position && action.position < action.total) { if (action && action.position && action.position < action.total) {
audio.currentTime = action.position audio.currentTime = action.position
state.started = audio.currentTime
} }
}, },
currentTime: (state, currentTime) => { currentTime: (state, currentTime) => {
@ -84,7 +86,10 @@ export const player = {
audio.pause() audio.pause()
context.dispatch('time') context.dispatch('time')
}, },
play: () => audio.play(), play: (context) => {
audio.play()
context.commit('started', audio.currentTime)
},
seek: (context, currentTime) => { seek: (context, currentTime) => {
audio.currentTime = currentTime audio.currentTime = currentTime
context.dispatch('time') context.dispatch('time')
@ -99,7 +104,7 @@ export const player = {
guid: context.state.episode.guid, guid: context.state.episode.guid,
action: 'play', action: 'play',
timestamp: moment().format('YYYY-MM-DD[T]HH:mm:ss'), timestamp: moment().format('YYYY-MM-DD[T]HH:mm:ss'),
started: Math.round(context.state.action ? context.state.action.started : 0), started: Math.round(context.state.started),
position: Math.round(audio.currentTime), position: Math.round(audio.currentTime),
total: Math.round(audio.duration), total: Math.round(audio.duration),
}]), }]),