Ver Fonte

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 há 2 meses atrás
pai
commit
5d83e79d71

+ 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)
       }
     }