重开一个组件再写当前播放完成

This commit is contained in:
zilong
2021-10-24 20:10:59 +08:00
parent 6a257b9c65
commit 9c7b484b36
9 changed files with 213 additions and 96 deletions

View File

@@ -75,7 +75,7 @@ const playNext = async (step) => {
case 3: //随机
if (playingList.length <= 1) return; //只有一首歌
const i = Math.floor(Math.random() * (playingList.length - 1));
if (i >= idx) idx = i+1;
if (i >= idx) idx = i + 1;
else idx = i;
break;
}
@@ -90,6 +90,18 @@ const forward = async () => {
playNext(1);
};
const stop = async () => {
pause();
if (store.state.settings.playingList.length < 1) {
audioEl.value.src = "";
lastPause = 0;
store.commit("saveSettings", {
songId: null,
});
pubsub.publish('zp.hideSongInfo')
}
};
const play = async (id, im = true) => {
console.log(id);
await getSongUrl(id)
@@ -177,6 +189,12 @@ const psToken = pubsub.subscribe("zp", (msg, data) => {
case "zp.play":
play(data.id, data.im);
break;
case "zp.next":
forward();
break;
case "zp.stop":
stop();
break;
case "zp.setProgressScale":
setProgressScale(data.scale);
break;
@@ -249,13 +267,13 @@ onUnmounted(() => {
</n-icon>
</template>
</n-button>
<n-button circle>
<!-- <n-button circle>
<template #icon>
<n-icon>
<TrashOutline />
</n-icon>
</template>
</n-button>
</n-button> -->
</n-space>
<!-- </div> -->