Browse Source

夺宝奇兵语音队列播放完成。

master^2
宋杰 2 days ago
parent
commit
0dc8c67cf5
  1. 52
      src/views/AIchat.vue

52
src/views/AIchat.vue

@ -657,9 +657,21 @@ watch(
audioStore.isPaused = false;
console.log(`${audioInfo.name}音频开始播放`);
},
onpause: () => {
audioStore.isPlaying = false;
audioStore.isPaused = true;
audioStore.playbackPosition = audio.seek() || 0;
console.log(`${audioInfo.name}音频已暂停,位置:`, audioStore.playbackPosition);
},
onresume: () => {
audioStore.isPlaying = true;
audioStore.isPaused = false;
console.log(`${audioInfo.name}音频继续播放`);
},
onend: () => {
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
isPlayingAudio.value = false;
console.log(`${audioInfo.name}音频播放完成`);
//
@ -667,6 +679,13 @@ watch(
playNextAudio();
}, 100);
},
onstop: () => {
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
isPlayingAudio.value = false;
console.log(`${audioInfo.name}音频已停止`);
},
onloaderror: (id, err) => {
console.error(`${audioInfo.name}音频播放失败:`, err);
isPlayingAudio.value = false;
@ -677,6 +696,8 @@ watch(
}
});
// URLstore
audioStore.setCurrentAudioUrl(audioInfo.url);
audioStore.nowSound = audio;
audioStore.setAudioInstance(audio);
audio.play();
@ -694,6 +715,37 @@ watch(
}
};
// audioStoretogglePlayPause
const originalTogglePlayPause = audioStore.togglePlayPause;
audioStore.togglePlayPause = () => {
console.log('主页音频控制按钮被点击');
console.log('当前音频状态 - isPlaying:', audioStore.isPlaying, 'isPaused:', audioStore.isPaused);
console.log('当前音频实例:', audioStore.soundInstance);
if (audioStore.soundInstance) {
if (audioStore.isPlaying) {
//
console.log('暂停当前音频');
audioStore.soundInstance.pause();
} else if (audioStore.isPaused && audioStore.playbackPosition > 0) {
//
console.log('从暂停位置继续播放音频,位置:', audioStore.playbackPosition);
audioStore.soundInstance.seek(audioStore.playbackPosition);
audioStore.soundInstance.play();
} else {
//
console.log('重新开始播放音频');
audioStore.soundInstance.play();
}
} else {
console.log('没有音频实例,尝试播放队列中的音频');
//
if (!isPlayingAudio.value && audioQueue.value.length > 0) {
playNextAudio();
}
}
};
//
const preloadAudio = (url, apiKey) => {
if (!url || !audioStore.isVoiceEnabled) {

Loading…
Cancel
Save