Skip to content

🐞 fix: 修复播放速率被误禁用,切换播放引擎时跨设备id的不兼容,seek后没有立刻发出 Seeked D-Bus 信号#894

Open
lrst6963 wants to merge 1 commit intoimsyy:devfrom
lrst6963:devs
Open

🐞 fix: 修复播放速率被误禁用,切换播放引擎时跨设备id的不兼容,seek后没有立刻发出 Seeked D-Bus 信号#894
lrst6963 wants to merge 1 commit intoimsyy:devfrom
lrst6963:devs

Conversation

@lrst6963
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 16, 2026 22:47
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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!

此拉取请求旨在提升播放器的稳定性和用户体验,通过修复多个与播放控制和设备管理相关的缺陷。它确保了播放速率和均衡器等功能能够根据当前播放引擎的实际能力正确启用或禁用,并优化了切换播放引擎时的设备兼容性。此外,还改进了与外部媒体集成模块的通信,确保了 seek 操作后播放进度的即时同步。

Highlights

  • 播放速率和均衡器功能修复: 修复了播放速率选项被错误禁用的问题,现在根据播放引擎的能力动态判断,并确保均衡器功能也基于引擎能力正确启用/禁用。
  • 跨引擎设备ID兼容性: 解决了切换播放引擎时,跨设备ID导致的不兼容问题,确保设备设置在引擎切换时能正确重置。
  • Seeked D-Bus 信号即时发送: 在进行 seek 操作后,立即发出 Seeked D-Bus 信号,以确保外部客户端及时刷新播放进度,避免进度更新被节流丢弃。
Changelog
  • native/external-media-integration/index.d.ts
    • TimelinePayload 接口中添加了可选的 seeked 属性,用于指示更新是否由 seek 操作触发。
  • native/external-media-integration/src/model.rs
    • 在 Rust 的 TimelinePayload 结构体中增加了 seeked 字段,并标记为可选。
  • native/external-media-integration/src/sys_media/linux.rs
    • 在处理 UpdateTimeline 命令时,如果 seeked 标志为真,则发出 Seeked D-Bus 信号。
  • src/components/Player/PlayerRightMenu.vue
    • 引入 useAudioManager
    • 更新了均衡器和播放速度选项的禁用逻辑,现在根据 audioManager.capabilities 动态判断。
  • src/components/Setting/config/play.ts
    • 在切换播放引擎类型时,如果引擎发生变化,则将 playDevice 重置为目标引擎的默认设备,以避免跨引擎设备ID不兼容。
    • 改进了对已保存音频设备的验证逻辑,确保其在当前设备列表中有效。
    • toggleOutputDevice 调用添加了 try-catch 块,以处理切换设备时可能发生的错误。
  • src/core/player/MediaSessionManager.ts
    • 修改了 sendMediaTimeline 调用,在 immediate 更新时传递 seeked: true,以确保 seek 操作的进度更新不会被节流丢弃。
  • src/core/player/PlayerController.ts
    • 更新了 setPlaybackRate 方法中的播放速率检查,现在使用 audioManager.capabilities.supportsRate 来判断当前引擎是否支持倍速播放。
    • toggleOutputDevice 方法改为 async,并移除了内部的错误处理,使其能够向上抛出错误。
  • src/core/player/PlayerIpc.ts
    • sendMediaTimeline 函数中添加了可选的 seeked 参数,并将其传递给 IPC 消息。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

本次合并请求包含了几项重要的修复和改进。通过重构逻辑以使用音频管理器的能力(capabilities),正确地解决了播放速率控制被错误禁用的问题。同时,通过在切换引擎时重置为默认设备,解决了设备 ID 不兼容的问题,并通过验证已保存的设备 ID 增强了系统的鲁棒性。此外,实现了在 seek 操作后立即分发 Seeked D-Bus 信号,提高了外部媒体控件的响应速度。整体代码质量很高,变更逻辑清晰且实现得当。我只在错误处理路径中发现一个潜在问题,并提供了一个建议。

} catch (e) {
console.error("获取 MPV 音频设备失败:", e);
if (!settingStore.playDevice || settingStore.playDevice === "default") {
if (!settingStore.playDevice) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

此处的条件修改似乎不正确。

在获取 MPV 设备列表失败并进入 catch 块的情况下,如果之前保存的设备是 "default",新的条件 !settingStore.playDevice 会评估为 false,这将导致 settingStore.playDevice 无法被设置为 MPV 引擎的正确默认值 "auto"

对于这种回退场景,原始的 !settingStore.playDevice || settingStore.playDevice === "default" 条件是正确的,建议恢复此逻辑以确保健壮性。

Suggested change
if (!settingStore.playDevice) {
if (!settingStore.playDevice || settingStore.playDevice === "default") {

Copy link
Contributor

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

该 PR 主要修复/完善播放器与系统媒体集成在「倍速能力判断」「切换播放引擎后的输出设备 ID 兼容性」「Seek 后立刻发出 Seeked D-Bus 信号」三方面的问题,覆盖前端播放控制、设置页设备管理,以及原生外部媒体集成(MPRIS)链路。

Changes:

  • 使用 audioManager.capabilities 统一判断倍速/均衡器等功能可用性,避免对特定引擎硬编码禁用。
  • 切换播放引擎时重置输出设备默认值,并在设备列表加载时校验已保存设备是否有效。
  • timeline IPC / 原生插件 payload 增加 seeked 标记,Linux MPRIS 在 seek 更新时发出 Seeked D-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);
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

toggleOutputDevice 改成 async 后,类内仍有调用点(例如 loadAndPlaythis.toggleOutputDevice())未 await / 未捕获 Promise,可能导致未处理的 Promise rejection(尤其是 WebAudio 的 setSinkId 失败时)。建议要么在调用处使用 await 并处理失败,要么用 void this.toggleOutputDevice().catch(...) 显式吞掉/记录错误,或在 toggleOutputDevice 内部恢复 try/catch。

Suggested change
await audioManager.setSinkId(device);
try {
await audioManager.setSinkId(device);
} catch (error) {
console.error("切换输出设备失败", error);
}

Copilot uses AI. Check for mistakes.
Comment on lines +238 to +246
/**
* @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) => {
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

sendMediaTimeline 的 JSDoc @description 仍写的是“更新…播放状态”,但该函数实际更新的是时间轴/进度(timeline)。建议把描述改成“更新媒体控件和 Discord RPC 的进度/时间轴”等,避免误导后续调用者。

Copilot uses AI. Check for mistakes.
} catch (e) {
console.error("获取 MPV 音频设备失败:", e);
if (!settingStore.playDevice || settingStore.playDevice === "default") {
if (!settingStore.playDevice) {
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

在 MPV 分支的异常兜底里(获取设备列表失败),现在只在 !settingStore.playDevice 时才回退到 "auto"。如果用户此前保存的是 WebAudio 的 "default"(跨引擎迁移/旧版本遗留很常见),这里会保留 "default",后续对 MPV 来说很可能是不兼容的设备 ID。建议把 "default"(以及其他明显不在 MPV 语义内的值)也视为无效并回退到 "auto"

Suggested change
if (!settingStore.playDevice) {
if (!settingStore.playDevice || settingStore.playDevice === "default") {

Copilot uses AI. Check for mistakes.
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.

1 participant

Comments