Skip to content

fix(audio-only-mode): handle AbortError on no-refresh video switch; add auto-enable on blur#3

Merged
GrassBlock1 merged 4 commits intomasterfrom
copilot/fix-auto-enable-switch-audio-mode
Mar 18, 2026
Merged

fix(audio-only-mode): handle AbortError on no-refresh video switch; add auto-enable on blur#3
GrassBlock1 merged 4 commits intomasterfrom
copilot/fix-auto-enable-switch-audio-mode

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 18, 2026

Two issues in the audio-only-mode component:

  1. With autoEnable on, switching videos without a page refresh caused an AbortError ("The fetching process for the media resource was aborted by the user agent at the user's request") from video.play(), silently failing the audio-mode switch.
  2. No mechanism existed to automatically enter audio mode when the user leaves the tab.

Changes

Fix: AbortError on no-refresh navigation

  • videoChange callback now waits 800 ms before calling switchToAudioMode(), letting the Bilibili player finish re-initialising the <video> element before we overwrite its src.
  • video.play() rejection handler now distinguishes AbortError from real errors — treats it as non-fatal (warns to console, returns cleanly) rather than surfacing an error toast. The next videoChange will retry.

Feature: auto-enable after 30 s of page blur

  • New option autoEnableOnBlur (default false, display name 失去焦点后自动启用) in index.ts.
  • Uses document.visibilitychange: starts a 30 s timer on hide, cancels on show. Calls switchToAudioMode() if still hidden and not already in audio mode.
  • Listener is registered idempotently (remove-then-add) and torn down in beforeDestroy.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…enable on blur

Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix auto-enable switch to audio-only mode issue fix(audio-only-mode): handle AbortError on no-refresh video switch; add auto-enable on blur Mar 18, 2026
Copilot AI requested a review from GrassBlock1 March 18, 2026 05:26
@GrassBlock1 GrassBlock1 marked this pull request as ready for review March 18, 2026 07:46
Copilot AI review requested due to automatic review settings March 18, 2026 07:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the audio-only-mode video component by making auto-enable more reliable across no-refresh video navigations and by adding an optional “auto-enable on tab blur” behavior.

Changes:

  • Add new autoEnableOnBlur option (default false) to enable audio mode after the page has been hidden for 30s.
  • Delay auto-enable on videoChange to reduce video.play() abort failures on no-refresh navigation.
  • Treat AbortError from video.play() as non-fatal and avoid showing an error toast for it.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
registry/lib/components/video/audio-only-mode/index.ts Adds autoEnableOnBlur option metadata.
registry/lib/components/video/audio-only-mode/AudioOnlyMode.vue Adds blur/visibility timer logic; delays auto-enable on videoChange; handles AbortError from play().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread registry/lib/components/video/audio-only-mode/AudioOnlyMode.vue
Comment thread registry/lib/components/video/audio-only-mode/AudioOnlyMode.vue Outdated
GrassBlock1 and others added 2 commits March 18, 2026 15:56
… initial mount

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@GrassBlock1 GrassBlock1 merged commit b485a4f into master Mar 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants