feat: 优化播放

This commit is contained in:
alger
2025-01-17 22:34:49 +08:00
parent 573023600a
commit a94e0efba5
3 changed files with 54 additions and 32 deletions
+12 -8
View File
@@ -167,6 +167,7 @@ import {
import type { SongResult } from '@/type/music';
import { getImgUrl, isElectron, isMobile, secondToMinute, setAnimationClass } from '@/utils';
import { showShortcutToast } from '@/utils/shortcutToast';
import { audioService } from '@/services/audioService';
import MusicFull from './MusicFull.vue';
@@ -282,16 +283,19 @@ const MusicFullRef = ref<any>(null);
// 播放暂停按钮事件
const playMusicEvent = async () => {
if (play.value) {
if (sound.value) {
sound.value.pause();
try {
if (play.value) {
audioService.pause();
store.commit('setPlayMusic', false);
} else {
audioService.play();
store.commit('setPlayMusic', true);
}
store.commit('setPlayMusic', false);
} else {
if (sound.value) {
sound.value.play();
} catch (error) {
console.log('error',error)
if (play.value) {
store.commit('nextPlay');
}
store.commit('setPlayMusic', true);
}
};