Browse Source

安卓切换音频时播放混乱的问题

dev
no99 8 hours ago
parent
commit
6bd7f37855
  1. 33
      src/views/AIchat.vue

33
src/views/AIchat.vue

@ -111,7 +111,7 @@ const playNextAudio = () => {
src: [audioInfo.url],
html5: false,
format: ["mp3", "acc"],
// rate: 1.2,
// rate: 2,
retryCount: 0,
onplay: () => {
audioStore.isPlaying = true;
@ -214,7 +214,6 @@ const addToAudioQueue = (url, name) => {
"当前队列顺序:",
audioQueue.value.map((item) => `${item.name}(${item.order})`)
);
//
if (
!isPlayingAudio.value &&
@ -275,6 +274,12 @@ const toggleVoiceForUser = (index) => {
chatStore.messages[chatStore.currentUserIndex].audioStatus = false;
}
//
if (audioStore.soundInstance) {
audioStore.soundInstance.stop();
audioStore.soundInstance = null;
}
audioPreloadStatus.one = { loaded: false, url: null };
audioPreloadStatus.two = { loaded: false, url: null };
audioPreloadStatus.three = { loaded: false, url: null };
@ -301,20 +306,22 @@ const toggleVoiceForUser = (index) => {
audioStore.soundInstance = null;
currentPlayIndex = 0;
isCallingPlayNext = false;
addToAudioQueue(chatStore.messages[index].audioArray[0], "API1-第一个");
addToAudioQueue(chatStore.messages[index].audioArray[1], "API2-第二个");
addToAudioQueue(chatStore.messages[index].audioArray[2], "API3-第三个");
addToAudioQueue(chatStore.messages[index].audioArray[3], "API4-第四个");
setTimeout(() => {
addToAudioQueue(chatStore.messages[index].audioArray[0], "API1-第一个");
addToAudioQueue(chatStore.messages[index].audioArray[1], "API2-第二个");
addToAudioQueue(chatStore.messages[index].audioArray[2], "API3-第三个");
addToAudioQueue(chatStore.messages[index].audioArray[3], "API4-第四个");
if (!audioStore.isVoiceEnabled) {
audioStore.toggleVoice();
} else {
if (audioStore.currentAudioUrl || audioStore.ttsUrl) {
audioStore.togglePlayPause();
} else {
if (!audioStore.isVoiceEnabled) {
audioStore.toggleVoice();
} else {
if (audioStore.currentAudioUrl || audioStore.ttsUrl) {
// audioStore.togglePlayPause();
} else {
audioStore.toggleVoice();
}
}
}
}, 100); // 100ms
} else {
if (!audioStore.isVoiceEnabled) {
console.log("1111");

Loading…
Cancel
Save