From 1d65481be813267d840f04ee3577d9c2abd933d3 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 16 Jan 2024 22:36:01 +0100 Subject: [PATCH] fix: handle started action --- src/store/player.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/store/player.js b/src/store/player.js index f14bab1..bebe25f 100644 --- a/src/store/player.js +++ b/src/store/player.js @@ -25,6 +25,7 @@ export const player = { paused: null, podcastUrl: null, volume: 1, + started: 0, rate: 1, }, mutations: { @@ -33,6 +34,7 @@ export const player = { if (action && action.position && action.position < action.total) { audio.currentTime = action.position + state.started = audio.currentTime } }, currentTime: (state, currentTime) => { @@ -84,7 +86,10 @@ export const player = { audio.pause() context.dispatch('time') }, - play: () => audio.play(), + play: (context) => { + audio.play() + context.commit('started', audio.currentTime) + }, seek: (context, currentTime) => { audio.currentTime = currentTime context.dispatch('time') @@ -99,7 +104,7 @@ export const player = { guid: context.state.episode.guid, action: 'play', 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), total: Math.round(audio.duration), }]),