Ongaku icon indicating copy to clipboard operation
Ongaku copied to clipboard

Leverage MediaPlayer.framework

Open spotlightishere opened this issue 1 year ago • 0 comments

MediaPlayer.framework (part of MusicKit.framework, providing similar functionality) has the ability to query the system player via MPSystemMusicPlayerController's systemMusicPlayer.

Unfortunately, its available is limited to Mac Catalyst applications. This leaves several questions regarding design: It is rather unstable. For example, querying was broken throughout the entirety of the Big Sur and Monterey release cycles, only being more dependable within macOS Ventura 13.4. Is this worth the effort?

A rudimentary attempt at this proved to be rather difficult, as there was no immediately easy way to make a Catalyst application not present UI. Perhaps it would make sense to migrate Catalyst functionality to a custom XPC service (doable, even if creating a listener isn't available as a public API.) Alternatively, it could be worth investigating whether MediaPlayer.framework has a way to query the current track as a private API underneath the macOS SDK - they appear to be very identical.

Regardless, we should likely retain our current NSNotification/AppleScript-oriented effort as a fallback. (Perhaps macOS 14.0 will be more kind...)

spotlightishere avatar May 07 '23 03:05 spotlightishere