mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 19:37:35 +08:00
fix: 修复播放异常问题(可能)
This commit is contained in:
@@ -82,6 +82,7 @@
|
||||
<script setup>
|
||||
import { musicStore } from "@/store";
|
||||
import { DeleteFour } from "@icon-park/vue-next";
|
||||
import { setSeek } from "@/utils/Player";
|
||||
import AllArtists from "@/components/DataList/AllArtists.vue";
|
||||
|
||||
const music = musicStore();
|
||||
@@ -91,8 +92,14 @@ const playListShow = ref(false);
|
||||
|
||||
// 改变播放索引
|
||||
const changeIndex = (index) => {
|
||||
try {
|
||||
music.persistData.playSongIndex = index;
|
||||
setSeek($player, 0);
|
||||
music.setPlayState(true);
|
||||
} catch (err) {
|
||||
console.error("切换失败:" + err);
|
||||
$message.error("切换失败,请刷新后重试");
|
||||
}
|
||||
};
|
||||
|
||||
// 监听播放列表显隐
|
||||
|
||||
@@ -426,7 +426,7 @@ watch(
|
||||
() => music.getPlaySongData,
|
||||
(val) => {
|
||||
// 清除播放地址
|
||||
soundUnload();
|
||||
// soundUnload();
|
||||
music.setPlaySongTime({ currentTime: 0, duration: 0 });
|
||||
songChange(val);
|
||||
}
|
||||
@@ -451,8 +451,6 @@ watch(
|
||||
val ? "play" : "pause",
|
||||
persistData.value.playVolume
|
||||
);
|
||||
} else {
|
||||
$message.error("播放器初始化失败,请重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
this.persistData.personalFmMode = value;
|
||||
if (value) {
|
||||
soundUnload();
|
||||
if (this.persistData.personalFmData.id) {
|
||||
if (this.persistData.personalFmData?.id) {
|
||||
this.persistData.playlists = [];
|
||||
this.persistData.playlists.push(this.persistData.personalFmData);
|
||||
this.persistData.playSongIndex = 0;
|
||||
@@ -403,7 +403,8 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
fadePlayOrPause($player, "play", this.persistData.playVolume);
|
||||
}
|
||||
if (listMode !== "single" && listLength > 1) {
|
||||
soundUnload();
|
||||
// soundUnload();
|
||||
setSeek($player, 0);
|
||||
}
|
||||
this.playState = true;
|
||||
}
|
||||
@@ -420,7 +421,8 @@ const useMusicDataStore = defineStore("musicData", {
|
||||
this.persistData.playlists[this.persistData.playSongIndex]?.id
|
||||
) {
|
||||
console.log("播放歌曲与上一次不一致");
|
||||
soundUnload();
|
||||
// soundUnload();
|
||||
setSeek($player, 0);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("出现错误:" + error);
|
||||
|
||||
Reference in New Issue
Block a user