-
![]()
toggleVoiceForUser(stock)" alt="喇叭" />
@@ -257,9 +257,22 @@ const toggleVoiceForUser = (stock) => {
// 如果当前点击的股票正在播放,则暂停
if (currentState.isPlaying) {
console.log('暂停当前股票音频:', stock.stockInfo?.name);
- stopAudio();
- emotionAudioStore.resetAudioState();
+ // 暂停音频而不是停止
+ if (emotionAudioStore.nowSound && emotionAudioStore.nowSound.playing()) {
+ emotionAudioStore.nowSound.pause();
+ emotionAudioStore.isPaused = true;
+ emotionAudioStore.isPlaying = false;
+ }
setStockAudioState(stock, { isPlaying: false, isPaused: true });
+ } else if (currentState.isPaused) {
+ // 如果当前股票处于暂停状态,则继续播放
+ console.log('继续播放当前股票音频:', stock.stockInfo?.name);
+ if (emotionAudioStore.nowSound) {
+ emotionAudioStore.nowSound.play();
+ emotionAudioStore.isPaused = false;
+ emotionAudioStore.isPlaying = true;
+ }
+ setStockAudioState(stock, { isPlaying: true, isPaused: false });
} else {
// 如果有其他音频正在播放,先停止
if (isAnyAudioPlaying) {