From e4693b1bdf7aac3d4e13e73afbd50a679b6e9d6e Mon Sep 17 00:00:00 2001 From: Hawtim Zhang Date: Thu, 22 Oct 2020 12:21:50 +0800 Subject: [PATCH] fix: scrobble error params type (#38) * feat: add config to resolve path alias. * feat: use vue-i18n for language switch * feat: add .editorconfig for ide * fix: add no-referrer to avoid CROB * fix: setCookie and fix typo * feat: integrate vue-i18n * feat: player component i18n support * fix: duplicate key warning in explore page * fix: like songs number changed in library page * fire: remove todo * fix: same text search on enter will cause error * fix: scrobble error params type --- src/store/actions.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/store/actions.js b/src/store/actions.js index a109d32..65299d4 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -7,14 +7,24 @@ export default { getTrackDetail(basicTrack.id).then(data => { let track = data.songs[0]; track.sort = basicTrack.sort; - + // 获取当前的播放时间。初始化为 loading 状态时返回 howler 的实例而不是浮点数时间,比如 1.332 let time = state.howler.seek(); + let currentTime = 0 + if (time === 0) { + // state.howler._duration 可以获得当前实例的播放时长 + currentTime = 180 + } + if (time.toString() === '[object Object]') { + currentTime = 0 + } + if (time > 0) { + currentTime = time + } scrobble({ id: state.player.currentTrack.id, sourceid: state.player.listInfo.id, - time: time === 0 ? 180 : time - }); - + time: currentTime + }) commit("updateCurrentTrack", track); updateMediaSessionMetaData(track); document.title = `${track.name} · ${track.ar[0].name} - YesPlayMusic`;