feat(plugin): MPRIS 媒体控制插件 — 支持分P、合集、单视频及封面同步精简版#6
Open
Copilot wants to merge 3 commits into
Open
Conversation
…ly syncs video cover artwork Agent-Logs-Url: https://github.com/BlockG-ws/b23-evolved/sessions/e1791125-b6e5-42e1-869c-7d92440d8e43 Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add MPRIS media control plugin for Bilibili videos
feat(plugin): MPRIS 媒体控制插件 — 支持分P、合集、单视频及封面同步精简版
May 11, 2026
GrassBlock1
approved these changes
May 11, 2026
There was a problem hiding this comment.
Pull request overview
This PR introduces a new video plugin that syncs the system Media Session (MPRIS) artwork to the current Bilibili video cover on each video switch.
Changes:
- Add
video.mpris-coverplugin to updatenavigator.mediaSession.metadata.artworkwhenvideoChangefires. - Fetch
VideoInfoon each video change to obtain the current video’s cover URL and apply it to Media Session metadata.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+19
to
+37
| videoChange(async ({ aid }) => { | ||
| let info: VideoInfo | ||
| try { | ||
| info = await new VideoInfo(String(aid)).fetchInfo() | ||
| } catch { | ||
| return | ||
| } | ||
|
|
||
| if (!info.coverUrl) { | ||
| return | ||
| } | ||
|
|
||
| const artwork: MediaImage[] = [{ src: info.coverUrl, sizes: COVER_SIZES, type: COVER_TYPE }] | ||
|
|
||
| if (ms.metadata) { | ||
| ms.metadata.artwork = artwork | ||
| } else { | ||
| ms.metadata = new MediaMetadata({ artwork }) | ||
| } |
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
@copilot apply changes based on this feedback
Author
There was a problem hiding this comment.
Fixed in fa3b64a. Added a requestId counter in the setup() closure. Each videoChange callback invocation increments it and captures its own currentId. After await, if currentId !== requestId the response is from a superseded request and is discarded.
Comment on lines
+8
to
+12
| export const plugin: PluginMetadata = { | ||
| name: 'video.mpris-cover', | ||
| displayName: 'MPRIS 封面同步', | ||
| description: `将系统媒体控制(MPRIS)的专辑封面替换为当前正在播放的 Bilibili 视频封面。`, | ||
| setup: () => { |
…o switch Agent-Logs-Url: https://github.com/BlockG-ws/b23-evolved/sessions/1af2cb60-a33a-447e-8eb6-217e53b05ddb Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增两个插件:完整 MPRIS 集成(
video.mpris)及仅同步封面的精简版(video.mpris-cover)。同时扩展VideoInfoAPI 以暴露ugc_season数据。src/components/video/video-info.tsUgcSeasonEpisodeInfo/UgcSeasonSectionInfo/UgcSeasonInfo接口VideoInfo新增ugcSeason?: UgcSeasonInfo字段,从data.ugc_season提取,无额外网络请求registry/lib/plugins/video/mpris(video.mpris)完整 MPRIS 集成:
setPositionState含 duration / position / playbackRate,每 5s 刷新,play / pause / ratechange 即时触发playerAgentvideoChange时自动刷新所有 metadata 与 handler,切换前清理事件监听与定时器registry/lib/plugins/video/mpris-cover(video.mpris-cover)精简版,仅在每次视频切换时将
navigator.mediaSession.metadata.artwork替换为当前视频封面;不含播放控制、进度同步或导航逻辑。修复:快速切换视频时的竞争条件
引入递增的
requestId计数器,防止快速切换视频时早期fetchInfo()响应在较新请求之后返回并覆盖当前封面。每次videoChange回调在await后校验currentId === requestId,若不一致则丢弃过期结果。