Skip to content

✨ feat: 改进 Windows 下的媒体控件集成#671

Merged
imsyy merged 14 commits into
SPlayer-Dev:devfrom
apoint123:feat/improve-media-control-integration
Dec 28, 2025
Merged

✨ feat: 改进 Windows 下的媒体控件集成#671
imsyy merged 14 commits into
SPlayer-Dev:devfrom
apoint123:feat/improve-media-control-integration

Conversation

@apoint123
Copy link
Copy Markdown
Member

通过引入一个 Electron 原生插件来实现与 Windows SMTC 的直接交互,可以传输更清晰的封面和更多的控制功能 (随机和循环播放等)

还可以引入一个 Discord RPC 集成,但需要你在 Discord 开发者面板 注册一个应用,或者我来注册一个

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

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

此拉取请求引入了一个用 Rust 编写的全新 Electron 本地插件,旨在显著增强 Windows 上的媒体控制集成。它通过与 Windows 系统媒体传输控件 (SMTC) 的直接交互,改进了媒体信息的显示和播放控制功能,同时还增加了 Discord Rich Presence (RPC) 功能,以在 Discord 上展示当前播放的音乐。

Highlights

  • Windows SMTC 集成: 引入了一个新的 Electron 原生插件,实现了与 Windows 系统媒体传输控件 (SMTC) 的直接交互,从而能够传输更清晰的封面艺术和支持更多的播放控制功能,例如随机播放和循环播放。
  • Discord Rich Presence (RPC) 集成: 该插件还集成了 Discord Rich Presence 功能,允许在 Discord 上显示当前正在播放的音乐信息,并支持自定义显示模式和暂停时的行为。
  • N-API 接口: 通过 N-API 接口,Rust 编写的本地插件向 Electron 应用程序暴露了一系列函数,用于控制 SMTC 和 Discord RPC 的功能,包括初始化、关闭、更新元数据、播放状态、时间线和播放模式等。
  • 日志系统: 为本地插件设置了一个结构化的日志系统,使用 tracing 库,支持每日滚动日志文件和控制台输出,便于调试和监控。
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
Copy Markdown
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

这个 Pull Request 通过引入一个 Rust 编写的原生插件,极大地改进了 Windows 上的媒体控件(SMTC)和 Discord RPC 集成,这是一个很棒的功能。代码结构清晰,模块划分合理,并且利用了异步处理来避免阻塞主线程。

然而,我发现了一些关键问题,主要涉及使用了尚未稳定的 Rust Nightly 功能(例如 edition = "2024"let_chains),这会导致代码在标准的稳定版 Rust 工具链上无法编译。此外,在 SMTC 元数据更新的逻辑中存在一个潜在的死锁问题。

我在代码中提出了具体的修改建议来修复这些问题,以确保代码的稳定性和兼容性。请查看具体的审查评论。

Comment thread native/smtc-for-splayer/Cargo.toml
Comment thread native/smtc-for-splayer/src/discord.rs
Comment thread native/smtc-for-splayer/src/discord.rs
Comment thread native/smtc-for-splayer/src/discord.rs
Comment thread native/smtc-for-splayer/src/smtc_core.rs
@apoint123 apoint123 force-pushed the feat/improve-media-control-integration branch from 41a2a90 to 520e434 Compare December 27, 2025 14:03
@apoint123 apoint123 force-pushed the feat/improve-media-control-integration branch from a21173a to 61e6478 Compare December 27, 2025 16:57
@apoint123 apoint123 marked this pull request as ready for review December 27, 2025 18:10
@apoint123
Copy link
Copy Markdown
Member Author

目前还有几个坑:

  • SMTC 双按钮和 SPlayer 单按钮的随机和循环播放模式映射非常反直觉
  • Discord RPC 集成暂未实现

不过这个 PR 已经有 2k 行新增代码了 (还有 2k 行是自动生成的锁文件),就不再在这个 PR 继续改了

@apoint123

This comment was marked as outdated.

Copy link
Copy Markdown
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

此次更新通过引入一个原生 Electron 插件,极大地改进了 Windows 平台下的媒体控件(SMTC)集成,并增加了 Discord Rich Presence 功能,这是一个非常出色的功能增强。代码整体结构清晰,尤其是在 TypeScript 和 Rust 两端都做了良好的抽象,例如 MediaSessionManagerPlayerIpc 的重构,以及原生模块中对 SMTC 和 Discord RPC 的分离处理。错误处理和异步操作的管理也做得很到位。我发现了一个会导致原生模块编译失败的关键问题,并提供了一些可以提高代码可维护性的建议。修复此问题后,这将是一次非常高质量的合并。

Comment thread native/smtc-for-splayer/Cargo.toml
Comment thread native/smtc-for-splayer/src/discord.rs
Comment thread electron/main/ipc/ipc-smtc.ts Outdated
@imsyy imsyy merged commit 874b044 into SPlayer-Dev:dev Dec 28, 2025
@apoint123 apoint123 deleted the feat/improve-media-control-integration branch December 28, 2025 16:00
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.

2 participants