musikcube icon indicating copy to clipboard operation
musikcube copied to clipboard

[macOS] Enable CLI Control & Full "Now Playing" via MPNowPlayingInfoCenter

Open Else00 opened this issue 5 months ago • 0 comments

Problem: No CLI Control for "Now Playing" Metadata on macOS

On macOS, while musikcube correctly responds to media keyboard commands (Play/Pause, Next Track, Previous Track), providing a basic level of system control, it currently lacks the ability to be reliably controlled or queried for track metadata from the command line interface (CLI).

Specifically, the "Now Playing" widget in the macOS Control Center, on the Lock Screen, and general-purpose macOS CLI tools like nowplaying-cli (which query system-level media information) show no information about the currently playing track when musikcube is active. They remain blank or display information from other applications if they were playing.

This behavior strongly indicates that musikcube is not publishing track metadata (such as title, artist, album, duration, etc.) to the MPNowPlayingInfoCenter. The MPNowPlayingInfoCenter is the macOS framework responsible for providing detailed "Now Playing" information to the system UI and, critically, to other applications and tools (including CLI utilities like nowplaying-cli) that wish to read or interact with it.

The working media keys confirm musikcube correctly registers with MPRemoteCommandCenter for receiving commands, but the lack of "Now Playing" metadata suggests it's not publishing information back to the system via MPNowPlayingInfoCenter.

Technical Details:

  • MPRemoteCommandCenter: musikcube appears to be correctly interacting with this component of the MediaRemote.framework to respond to system media commands (e.g., from physical keyboard keys).
  • MPNowPlayingInfoCenter: It seems musikcube does not currently populate or update the MPNowPlayingInfoCenter. As a result, the macOS system has no metadata to display for the currently playing track from musikcube, which in turn prevents other tools from accessing this information.
  • nowplaying-cli: This command-line tool, which queries the MediaRemote.framework for currently playing information, returns empty or no relevant data when musikcube is the active player because musikcube is not providing that data to the system. This blocks CLI-based querying of track information.
  • Contrast with Linux (playerctl / MPRIS): On Linux, musikcube users can leverage playerctl (which uses MPRIS/D-Bus) to get current track information and control playback from the CLI. macOS uses a completely different set of APIs, and playerctl is not applicable. A similar level of CLI integration is desired for macOS users.

Proposed Solution / Feature Request:

To enable comprehensive CLI control and allow macOS system features to display musikcube's "Now Playing" information, it is requested that musikcube implement full integration with the macOS MediaRemote.framework by populating the MPNowPlayingInfoCenter with the currently playing track's metadata.

This would involve:

  1. Updating the nowPlayingInfo dictionary within the MPNowPlayingInfoCenter whenever the track changes or playback state updates.
  2. Optionally, implementing other MPRemoteCommandCenter handlers for more granular control (e.g., seekBackward, seekForward, changePlaybackRate) if not already fully supported.

Benefits:

Implementing this feature would provide several significant improvements for musikcube users on macOS:

  • CLI Control & Querying: This is the primary benefit, enabling users to write scripts, create custom shortcuts, or use tools like nowplaying-cli to get current song information (nowplaying-cli get title, get artist) and control playback (nowplaying-cli play, pause, next-track) directly from the terminal.
  • Native "Now Playing" Widget: Display of track title, artist, and album in the macOS Control Center, Notification Center, and Lock Screen.
  • Touch Bar Integration: Correct track information and controls on MacBooks with a Touch Bar.
  • Enhanced User Experience: A more seamless and integrated experience within the macOS ecosystem, bringing musikcube's CLI capabilities closer to what's available on Linux.

Environment:

  • macOS Version: 15.5
  • musikcube Version: 3.0.4

Else00 avatar Jul 01 '25 08:07 Else00