Skip to content

fix(audio-only-mode): fix build errors, implement true audio-only streaming, update icons#1

Merged
GrassBlock1 merged 6 commits intomasterfrom
copilot/fix-build-error-and-update-audio-mode
Mar 17, 2026
Merged

fix(audio-only-mode): fix build errors, implement true audio-only streaming, update icons#1
GrassBlock1 merged 6 commits intomasterfrom
copilot/fix-build-error-and-update-audio-mode

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 17, 2026

The audio-only-mode component had multiple syntax/type errors preventing it from building, and its core logic only switched to lowest-quality video rather than actually fetching an audio-only stream.

Build Fixes

index.ts

  • Remove invalid playerUrls import from @/core/utils (not re-exported there)
  • Fix componentsTags. video space typo
  • Refactor to entry: none + widget pattern (consistent with downloadVideo and similar components)
  • Export Options type and options metadata (autoEnable, rememberProgress)
  • Fix prettier formatting errors

AudioOnlyMode.vue

  • Fix Vue. extend, unsafeWindow. aid, addComponentListener('audioOnlyMode. autoEnable' space typos
  • Fix broken CSS selectors (. bpx-menu-item, li. bui-select-item, . audio-only-mode-widget)
  • Remove unused getPlayerAgent import and currentAid data property
  • await video.play() and re-throw on rejection so isAudioMode is never set to true when playback fails; the outer catch block surfaces a Toast with the failure reason
  • Fix prettier formatting errors (template attribute formatting, trailing newlines)

Audio-Only Stream

Replaces the quality-switcher hack with Bilibili's DASH API (fnval: 16), using existing bilibiliApi/getJsonWithCredentials infrastructure. Selects highest-bandwidth audio track and sets video.src directly — no video stream is ever fetched.

const params = formData({ avid: unsafeWindow.aid, cid: unsafeWindow.cid,
  qn: 30280, otype: 'json', fourk: 1, fnver: 0, fnval: 16 })
const data = await bilibiliApi(getJsonWithCredentials(apiUrl), '获取音频链接失败')
const bestAudio = (data.dash.audio as AudioStream[]).reduce(
  (best, curr) => (curr.bandwidth > best.bandwidth ? curr : best), data.dash.audio[0])
video.src = (bestAudio.baseUrl || bestAudio.base_url || '').replace('http:', 'https:')
await video.play().catch((err: Error) => { throw new Error(`播放失败: ${err.message}`) })

Icons

Switched from mdi-volume-high/mdi-volume-offmdi-headphones/mdi-headphones-off to better represent audio-only mode.


🔒 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.

…e component

Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build error and update to audio only mode fix(audio-only-mode): fix build errors, implement true audio-only streaming, update icons Mar 17, 2026
Copilot AI requested a review from GrassBlock1 March 17, 2026 12:56
@GrassBlock1 GrassBlock1 marked this pull request as ready for review March 17, 2026 13:07
Copilot AI review requested due to automatic review settings March 17, 2026 13:07
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 fixes build-breaking issues in the audio-only-mode component and replaces the prior “switch to lowest video quality” approach with true audio-only playback by fetching an audio-only DASH stream and assigning it to the player element.

Changes:

  • Refactors component registration to the entry: none + widget pattern and adds options metadata (autoEnable, rememberProgress).
  • Implements audio-only streaming via Bilibili playurl DASH API (fnval: 16) and selects an audio track to play directly.
  • Updates widget icons and fixes several syntax/CSS selector typos in the Vue component.

Reviewed changes

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

File Description
registry/lib/components/video/audio-only-mode/index.ts Moves to widget-based component metadata and defines/export options.
registry/lib/components/video/audio-only-mode/AudioOnlyMode.vue Implements audio-only DASH fetching/playback logic; fixes typos and updates icons/styles.

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

Comment on lines +117 to +122
}
const bestAudio = (data.dash.audio as AudioStream[]).reduce(
(best, curr) => (curr.bandwidth > best.bandwidth ? curr : best),
data.dash.audio[0] as AudioStream,
)
const audioUrl = (bestAudio.baseUrl || bestAudio.base_url || '').replace('http:', 'https:')

video.src = audioUrl
video.load()
video.play()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@copilot 在 video 播放失败时失败时给出 Toast 或显式 .catch()并避免将 isAudioMode 置为 true。
#1 (comment)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 5851a1bvideo.play() is now awaited and failures are re-thrown as a wrapped Error, so isAudioMode stays false and the catch block shows a Toast with the failure reason.

GrassBlock1 and others added 2 commits March 17, 2026 21:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…dioMode

Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@GrassBlock1
Copy link
Copy Markdown

@copilot please fix eslint errors

Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 17, 2026

@copilot please fix eslint errors

Fixed in 17b3205 — 4 prettier formatting errors in AudioOnlyMode.vue and index.ts have been auto-fixed (trailing newlines and template attribute formatting).

Copilot AI requested a review from GrassBlock1 March 17, 2026 13:30
@GrassBlock1 GrassBlock1 merged commit ff4cfb9 into master Mar 17, 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