Skip to content

feat: add Windows SMTC (System Media Transport Controls) support - #737

Open
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:feat/win-smtc-support
Open

feat: add Windows SMTC (System Media Transport Controls) support#737
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:feat/win-smtc-support

Conversation

@kt286

@kt286 kt286 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Implement Windows SMTC integration so the system media overlay can display current track info and respond to play/pause/next/previous commands, similar to MPRIS on Linux.

  • Add WinSMTC class wrapping WinRT ISystemMediaTransportControls API with playback status sync, metadata (title/artist/album/cover art), and button press event handling
  • Create Start Menu shortcut with AppUserModelID for SMTC identification
  • Integrate SMTC into PlayerEngine with playback state and metadata sync
  • Expose Presenter::playerEngine() for SMTC initialization from main
  • Guard MPRIS/DBus adaptor registration with Q_OS_LINUX
  • Link WinRT libraries (runtimeobject, ole32, user32, propsys, shell32)

feat: 添加 Windows SMTC(系统媒体传输控件)支持

实现 Windows SMTC 集成,使系统媒体覆盖层可以显示当前曲目信息并响应
播放/暂停/下一曲/上一曲命令,类似 Linux 上的 MPRIS。

  • 新增 WinSMTC 类,封装 WinRT ISystemMediaTransportControls API, 支持播放状态同步、元数据(标题/艺术家/专辑/封面)及按键事件处理
  • 创建开始菜单快捷方式并设置 AppUserModelID 用于 SMTC 识别
  • 在 PlayerEngine 中集成 SMTC,同步播放状态和元数据
  • 暴露 Presenter::playerEngine() 供 main 中初始化 SMTC
  • 使用 Q_OS_LINUX 守卫 MPRIS/DBus adaptor 注册
  • 链接 WinRT 库(runtimeobject、ole32、user32、propsys、shell32)

Summary by Sourcery

Integrate Windows system media controls into the player while preserving Linux-only MPRIS behavior.

New Features:

  • Add Windows System Media Transport Controls integration for track metadata, playback state, cover art, and media button commands.

Enhancements:

  • Keep Linux MPRIS and DBus integration platform-specific while exposing the player engine for platform media-control initialization.

Build:

  • Link the Windows libraries required by SMTC support.

Tests:

  • Update player engine and presenter tests to accommodate platform-specific MPRIS initialization.

Chores:

  • Create a Windows Start Menu shortcut with an AppUserModelID for SMTC registration.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @kt286, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kt286

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

Hi @kt286. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds Windows System Media Transport Controls (SMTC) integration, wiring WinRT media controls into PlayerEngine and main startup, while keeping existing MPRIS/DBus logic Linux-only and linking required Windows libraries.

Sequence diagram for Windows SMTC initialization and playback sync

sequenceDiagram
    participant Main
    participant Presenter
    participant PlayerEngine
    participant WinSMTC

    Main->>WinSMTC: ensureStartMenuShortcut()
    Main->>Presenter: playerEngine()
    Presenter-->>Main: PlayerEngine*
    Main->>PlayerEngine: setWinSMTC(hwnd)
    PlayerEngine->>WinSMTC: WinSMTC(this)
    PlayerEngine->>WinSMTC: initialize(hwnd)
    WinSMTC-->>PlayerEngine: initialized

    PlayerEngine->>PlayerEngine: resetDBusMpris(meta)
    PlayerEngine->>WinSMTC: updateMetadata(title, artist, album, length, artPath)

    PlayerEngine->>PlayerEngine: [playbackStatusChanged]
    PlayerEngine->>WinSMTC: updatePlaybackStatus(status)
Loading

Sequence diagram for Windows SMTC button handling

sequenceDiagram
    actor User
    participant SystemSMTC
    participant WinSMTC
    participant PlayerEngine

    User->>SystemSMTC: media key press
    SystemSMTC-->>WinSMTC: ButtonPressedEvent
    WinSMTC-->>PlayerEngine: playRequested()
    PlayerEngine->>PlayerEngine: resume() / play() / pauseNow()

    User->>SystemSMTC: next key
    SystemSMTC-->>WinSMTC: ButtonPressedEvent
    WinSMTC-->>PlayerEngine: nextRequested()
    PlayerEngine->>PlayerEngine: playNextMeta(false)

    User->>SystemSMTC: previous key
    SystemSMTC-->>WinSMTC: ButtonPressedEvent
    WinSMTC-->>PlayerEngine: previousRequested()
    PlayerEngine->>PlayerEngine: playPreMeta()
Loading

File-Level Changes

Change Details Files
Integrate Windows SMTC control object into PlayerEngine lifecycle and sync playback state/metadata.
  • Declare WinSMTC member in PlayerEnginePrivate behind Q_OS_WIN guard and clean it up in the destructor.
  • Expose setWinSMTC(void *hwnd) on PlayerEngine to initialize WinSMTC with the main window handle.
  • Wire SMTC play/pause/stop/next/previous signals to existing PlayerEngine slots and playlist logic.
  • Mirror playbackStatus and metadata (title/artist/album/length/art) into SMTC, including enabling/disabling transport buttons based on playlist navigation availability.
src/libdmusic/player/playerengine.cpp
src/libdmusic/player/playerengine.h
Expose access to PlayerEngine from Presenter to allow SMTC initialization from the GUI startup path.
  • Add forward declaration for PlayerEngine in presenter.h.
  • Add playerEngine() const accessor returning m_playerEngine in Presenter.
  • Adjust presenter headers’ SPDX-FileCopyrightText comments.
src/libdmusic/presenter.cpp
src/libdmusic/presenter.h
Initialize Windows-specific process/AppUserModelID state and hook SMTC at application startup while guarding Linux-only behaviors.
  • Include Windows headers in main.cpp under Q_OS_WIN and guard POSIX signal-related includes/handlers with Q_OS_LINUX.
  • Set the process AppUserModelID dynamically via shell32 at startup and call WinSMTC::ensureStartMenuShortcut().
  • After QML engine load, locate the main QWindow, set its icon, and pass its HWND to presenter->playerEngine()->setWinSMTC().
  • Guard DBus adaptor registration and SIGTERM handling so they only run on Linux.
src/music-player/main.cpp
Implement WinSMTC helper class wrapping WinRT ISystemMediaTransportControls and handling Start Menu shortcut creation.
  • Create winsmtc.h defining WinSMTC QObject with initialize/shutdown, metadata/playback status update, and control enabling APIs plus Qt signals for control requests.
  • Implement winsmtc.cpp to obtain ISystemMediaTransportControls for a window via ISystemMediaTransportControlsInterop, set up display metadata/thumbnail via WinRT streams, and update playback status and button capabilities.
  • Implement ButtonDelegate ITypedEventHandler to translate WinRT button events into Qt signals on WinSMTC.
  • Provide static ensureStartMenuShortcut() to create a localized Start Menu .lnk with AppUserModelID and icon, cleaning up older shortcuts.
src/libdmusic/player/winsmtc.h
src/libdmusic/player/winsmtc.cpp
Link required WinRT/Windows libraries for SMTC on Windows builds.
  • Add conditional CMake logic for WIN32 and non-MSVC toolchains to link runtimeobject, ole32, user32, propsys, and shell32.
  • Update SPDX headers in several source files to extend the year range to 2026.
src/libdmusic/CMakeLists.txt
src/libdmusic/player/playerengine.cpp
src/libdmusic/player/playerengine.h
src/libdmusic/presenter.cpp
src/libdmusic/presenter.h
src/music-player/main.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kt286
kt286 force-pushed the feat/win-smtc-support branch 7 times, most recently from 2b69612 to c774bc5 Compare August 11, 2026 00:57
@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.63
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #762

@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.64
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #765

@kt286
kt286 force-pushed the feat/win-smtc-support branch from c774bc5 to ac1ebd0 Compare August 18, 2026 05:26
@deepin-bot

deepin-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.65
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #768

@deepin-bot

deepin-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.66
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #779

@kt286
kt286 force-pushed the feat/win-smtc-support branch from ac1ebd0 to 630eb0e Compare August 21, 2026 01:40
- Add Windows System Media Transport Controls (SMTC) support
- Wrap MprisPlayer include and usage in Q_OS_LINUX ifdef
- Use void* placeholder for non-Linux platforms to maintain ABI
- Add platform guards for setMprisPlayer in presenter and main
- Update tests to conditionally compile MPRIS-dependent code

feat: 添加 Windows SMTC 支持并为 MPRIS 添加 Linux 条件编译

- 新增 Windows System Media Transport Controls (SMTC) 支持
- 使用 Q_OS_LINUX ifdef 将 MprisPlayer 包裹为仅 Linux 可用
- 非 Linux 平台使用 void* 占位符保持 ABI 兼容
- 为 presenter 和 main 中的 setMprisPlayer 添加平台保护
- 更新测试代码的条件编译
@kt286
kt286 force-pushed the feat/win-smtc-support branch from 630eb0e to eb4023a Compare August 21, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants