Просмотр исходного кода

fix: ignore AbortError from interrupted audio.play() in useAudioPlayer

stop() pauses the audio element while its play() Promise is
still pending, which rejects with DOMException(AbortError).
The inner catch was treating that as a real failure and
setting errorId, so an intentional interrupt (e.g., user
starts recording during AI auto-play) would leave a phantom
"点击重试" UI on the message that played fine.

Distinguish AbortError from autoplay-policy / decoder errors
the same way the synthesis catch does — silent return.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jimmylee 2 месяцев назад
Родитель
Сommit
7e7b7719ee
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      src/views/Editor/EnglishSpeaking/composables/useAudioPlayer.ts

+ 4 - 1
src/views/Editor/EnglishSpeaking/composables/useAudioPlayer.ts

@@ -108,8 +108,11 @@ export function useAudioPlayer(): AudioPlayer {
         await audio.play()
       }
       catch (err) {
-        // Most often: autoplay policy blocked the call.
         if (currentAudio === audio) currentAudio = null
+        // pause() during a pending play() rejects with AbortError —
+        // that is an intentional interrupt (from stop()), not a failure.
+        if (err instanceof DOMException && err.name === 'AbortError') return
+        // Most often: autoplay policy blocked the call.
         failPlayback(id, err)
       }
     }