fix(audio-only-mode): fix build errors, implement true audio-only streaming, update icons#1
Conversation
…e component Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
There was a problem hiding this comment.
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+widgetpattern 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.
registry/lib/components/video/audio-only-mode/AudioOnlyMode.vue
Outdated
Show resolved
Hide resolved
| } | ||
| 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() |
There was a problem hiding this comment.
@copilot 在 video 播放失败时失败时给出 Toast 或显式 .catch()并避免将 isAudioMode 置为 true。
#1 (comment)
There was a problem hiding this comment.
Fixed in 5851a1b — video.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.
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>
|
@copilot please fix eslint errors |
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
The
audio-only-modecomponent 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.tsplayerUrlsimport from@/core/utils(not re-exported there)componentsTags. videospace typoentry: none+widgetpattern (consistent withdownloadVideoand similar components)Optionstype andoptionsmetadata (autoEnable,rememberProgress)AudioOnlyMode.vueVue. extend,unsafeWindow. aid,addComponentListener('audioOnlyMode. autoEnable'space typos. bpx-menu-item,li. bui-select-item,. audio-only-mode-widget)getPlayerAgentimport andcurrentAiddata propertyawait video.play()and re-throw on rejection soisAudioModeis never set totruewhen playback fails; the outercatchblock surfaces a Toast with the failure reasonAudio-Only Stream
Replaces the quality-switcher hack with Bilibili's DASH API (
fnval: 16), using existingbilibiliApi/getJsonWithCredentialsinfrastructure. Selects highest-bandwidth audio track and setsvideo.srcdirectly — no video stream is ever fetched.Icons
Switched from
mdi-volume-high/mdi-volume-off→mdi-headphones/mdi-headphones-offto 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.