最近播放完成一半,差清除列表

This commit is contained in:
zilong
2021-10-19 19:17:45 +08:00
parent 0de746e55b
commit 2905728772
8 changed files with 237 additions and 78 deletions

View File

@@ -12,7 +12,7 @@ import { getSongUrl } from "@/network/song";
import pubsub from "pubsub-js";
const store = useStore();
const { settings } = store.state;
// const { settings } = store.state;
const audioEl = ref("");
const playing = ref(false);
let currentTime = 0;
@@ -23,9 +23,9 @@ onMounted(() => {
audioEl.value.addEventListener("pause", onPause);
audioEl.value.addEventListener("ended", onEnd);
if (settings.songId) {
if (store.state.settings.songId) {
pubsub.publish("zp.play", {
id: settings.songId,
id: store.state.settings.songId,
im: false,
});
// play(settings.songId, false)
@@ -60,12 +60,13 @@ const play = async (id, im = true) => {
store.commit("saveSettings", {
songId: id,
});
pubsub.publish('zp.getSongInfo', {id})
pubsub.publish('zp.getSongInfo', {id: store.state.settings.songId, im})
if (im) {
audioEl.value.play();
playing.value = true;
}
}
})
.catch((err) => {
@@ -84,11 +85,12 @@ const resume = async () => {
// console.log(Date.now() - lastPause);
if (Date.now() - lastPause > 1000 * 60 * 5) {
console.log("暂停过了5分钟再次载入歌曲");
await play(settings.songId, false);
await play(store.state.settings.songId, false);
audioEl.value.currentTime = currentTime;
}
audioEl.value.play();
playing.value = true;
pubsub.publish('zp.getSongInfo', {id: store.state.settings.songId, im: true})
}
};