fix web playback log behavior

This commit is contained in:
2022-11-05 01:24:40 +08:00
parent 061ef9bdc9
commit e40fd2625f

View File

@@ -28,8 +28,11 @@ function AudioPlayer(props) {
if (file_id === null) {
return
}
const player = document.getElementById('dom-player')
const endPlayTime = new Date()
const duration = parseInt((endPlayTime - beginPlayTime) / 1000)
let duration = parseInt((endPlayTime - beginPlayTime) / 1000)
const maxDuration = parseInt(player.duration)
duration = duration < maxDuration ? duration : maxDuration
setBeginPlayTime(endPlayTime)
await fetch('/api/v1/record_playback', {
method: "POST",
@@ -248,11 +251,7 @@ function AudioPlayer(props) {
// 1 music finished
recordPlaybackHistory(props.playingFile.id, 1)
}}
onPause={() => {
// 4 music paused
recordPlaybackHistory(props.playingFile.id, 4)
}}
onPlay={() => {
onPlay={async () => {
setBeginPlayTime(new Date());
}}
></audio>