🐞 fix: 修复播放速率被误禁用,切换播放引擎时跨设备id的不兼容,seek后没有立刻发出 Seeked D-Bus 信号#894
🐞 fix: 修复播放速率被误禁用,切换播放引擎时跨设备id的不兼容,seek后没有立刻发出 Seeked D-Bus 信号#894
Conversation
Summary of ChangesHello @lrst6963, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在提升播放器的稳定性和用户体验,通过修复多个与播放控制和设备管理相关的缺陷。它确保了播放速率和均衡器等功能能够根据当前播放引擎的实际能力正确启用或禁用,并优化了切换播放引擎时的设备兼容性。此外,还改进了与外部媒体集成模块的通信,确保了 Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| } catch (e) { | ||
| console.error("获取 MPV 音频设备失败:", e); | ||
| if (!settingStore.playDevice || settingStore.playDevice === "default") { | ||
| if (!settingStore.playDevice) { |
There was a problem hiding this comment.
此处的条件修改似乎不正确。
在获取 MPV 设备列表失败并进入 catch 块的情况下,如果之前保存的设备是 "default",新的条件 !settingStore.playDevice 会评估为 false,这将导致 settingStore.playDevice 无法被设置为 MPV 引擎的正确默认值 "auto"。
对于这种回退场景,原始的 !settingStore.playDevice || settingStore.playDevice === "default" 条件是正确的,建议恢复此逻辑以确保健壮性。
| if (!settingStore.playDevice) { | |
| if (!settingStore.playDevice || settingStore.playDevice === "default") { |
There was a problem hiding this comment.
Pull request overview
该 PR 主要修复/完善播放器与系统媒体集成在「倍速能力判断」「切换播放引擎后的输出设备 ID 兼容性」「Seek 后立刻发出 Seeked D-Bus 信号」三方面的问题,覆盖前端播放控制、设置页设备管理,以及原生外部媒体集成(MPRIS)链路。
Changes:
- 使用
audioManager.capabilities统一判断倍速/均衡器等功能可用性,避免对特定引擎硬编码禁用。 - 切换播放引擎时重置输出设备默认值,并在设备列表加载时校验已保存设备是否有效。
- timeline IPC / 原生插件 payload 增加
seeked标记,Linux MPRIS 在 seek 更新时发出SeekedD-Bus 信号。
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/player/PlayerIpc.ts | timeline IPC payload 增加 seeked 参数并透传到主进程 |
| src/core/player/PlayerController.ts | 倍速逻辑改为基于 capabilities;切换输出设备改为 async/await |
| src/core/player/MediaSessionManager.ts | seek 触发的立即 timeline 更新标记为 seeked=true |
| src/components/Setting/config/play.ts | 引擎切换时重置默认设备;校验保存的设备 ID 是否仍有效;切换设备时增加错误提示 |
| src/components/Player/PlayerRightMenu.vue | 菜单项是否可用改为基于 capabilities(均衡器/倍速) |
| native/external-media-integration/src/sys_media/linux.rs | seeked=true 时发送 MPRIS Seeked 信号 |
| native/external-media-integration/src/model.rs | TimelinePayload 增加 seeked?: boolean 字段 |
| native/external-media-integration/index.d.ts | 同步更新 TimelinePayload 类型声明 |
| } catch (error) { | ||
| console.error("AudioManager: 设置输出设备失败", error); | ||
| } | ||
| await audioManager.setSinkId(device); |
There was a problem hiding this comment.
toggleOutputDevice 改成 async 后,类内仍有调用点(例如 loadAndPlay 里 this.toggleOutputDevice())未 await / 未捕获 Promise,可能导致未处理的 Promise rejection(尤其是 WebAudio 的 setSinkId 失败时)。建议要么在调用处使用 await 并处理失败,要么用 void this.toggleOutputDevice().catch(...) 显式吞掉/记录错误,或在 toggleOutputDevice 内部恢复 try/catch。
| await audioManager.setSinkId(device); | |
| try { | |
| await audioManager.setSinkId(device); | |
| } catch (error) { | |
| console.error("切换输出设备失败", error); | |
| } |
| /** | ||
| * @description 通过外部媒体集成模块更新媒体控件和 Discord RPC 的播放状态 | ||
| * @note 仅在 Electron 上有效 | ||
| * @param currentTime - 当前的播放进度,单位是毫秒 | ||
| * @param totalTime - 总时长,单位是毫秒 | ||
| * @param seeked - 是否为 seek 操作触发的更新 | ||
| * @see {@link EmiModule.updateTimeline 外部媒体集成模块的 `updateTimeline` 方法} | ||
| */ | ||
| export const sendMediaTimeline = (currentTime: number, totalTime: number) => { | ||
| export const sendMediaTimeline = (currentTime: number, totalTime: number, seeked?: boolean) => { |
There was a problem hiding this comment.
sendMediaTimeline 的 JSDoc @description 仍写的是“更新…播放状态”,但该函数实际更新的是时间轴/进度(timeline)。建议把描述改成“更新媒体控件和 Discord RPC 的进度/时间轴”等,避免误导后续调用者。
| } catch (e) { | ||
| console.error("获取 MPV 音频设备失败:", e); | ||
| if (!settingStore.playDevice || settingStore.playDevice === "default") { | ||
| if (!settingStore.playDevice) { |
There was a problem hiding this comment.
在 MPV 分支的异常兜底里(获取设备列表失败),现在只在 !settingStore.playDevice 时才回退到 "auto"。如果用户此前保存的是 WebAudio 的 "default"(跨引擎迁移/旧版本遗留很常见),这里会保留 "default",后续对 MPV 来说很可能是不兼容的设备 ID。建议把 "default"(以及其他明显不在 MPV 语义内的值)也视为无效并回退到 "auto"。
| if (!settingStore.playDevice) { | |
| if (!settingStore.playDevice || settingStore.playDevice === "default") { |
No description provided.