mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
refactor: Adjusting music initialization logic
1. Initial music loads twice on app start, a second load is triggered as soon as the page is clicked. So I close autounlock 2. Unplayable music can’t be play
This commit is contained in:
parent
ddebec9de9
commit
200c49e8c9
5 changed files with 33 additions and 42 deletions
|
|
@ -12,13 +12,13 @@ const ipcRenderer =
|
|||
process.env.IS_ELECTRON === true ? electron.ipcRenderer : null;
|
||||
|
||||
export default {
|
||||
switchTrack({ state, dispatch, commit }, basicTrack) {
|
||||
getTrackDetail(basicTrack.id).then((data) => {
|
||||
switchTrack({ state, dispatch, commit }, { id, sort = 0, autoplay = true }) {
|
||||
getTrackDetail(id).then((data) => {
|
||||
let track = data.songs[0];
|
||||
track.sort = basicTrack.sort;
|
||||
track.sort = sort;
|
||||
|
||||
// 获取当前的播放时间。初始化为 loading 状态时返回 howler 的实例而不是浮点数时间,比如 1.332
|
||||
let time = state.howler.seek();
|
||||
let time = state.howler ? state.howler.seek() : 0;
|
||||
let currentTime = 0;
|
||||
if (time === 0) {
|
||||
// state.howler._duration 可以获得当前实例的播放时长
|
||||
|
|
@ -54,7 +54,7 @@ export default {
|
|||
}
|
||||
|
||||
function commitMP3(mp3) {
|
||||
commit("replaceMP3", mp3);
|
||||
commit("replaceMP3", { mp3, autoplay });
|
||||
state.howler.once("end", () => {
|
||||
dispatch("nextTrack");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue