-
-
Save SKaplanOfficial/f9f5bdd6455436203d0d318c078358de to your computer and use it in GitHub Desktop.
| function run() { | |
| const MediaRemote = $.NSBundle.bundleWithPath('/System/Library/PrivateFrameworks/MediaRemote.framework/'); | |
| MediaRemote.load | |
| const MRNowPlayingRequest = $.NSClassFromString('MRNowPlayingRequest'); | |
| const appName = MRNowPlayingRequest.localNowPlayingPlayerPath.client.displayName; | |
| const infoDict = MRNowPlayingRequest.localNowPlayingItem.nowPlayingInfo; | |
| const title = infoDict.valueForKey('kMRMediaRemoteNowPlayingInfoTitle'); | |
| const album = infoDict.valueForKey('kMRMediaRemoteNowPlayingInfoAlbum'); | |
| const artist = infoDict.valueForKey('kMRMediaRemoteNowPlayingInfoArtist'); | |
| return `${title.js} — ${album.js} — ${artist.js} | ${appName.js}`; | |
| } |
| use framework "AppKit" | |
| on run | |
| set MediaRemote to current application's NSBundle's bundleWithPath:"/System/Library/PrivateFrameworks/MediaRemote.framework/" | |
| MediaRemote's load() | |
| set MRNowPlayingRequest to current application's NSClassFromString("MRNowPlayingRequest") | |
| set appName to MRNowPlayingRequest's localNowPlayingPlayerPath()'s client()'s displayName() | |
| set infoDict to MRNowPlayingRequest's localNowPlayingItem()'s nowPlayingInfo() | |
| set title to (infoDict's valueForKey:"kMRMediaRemoteNowPlayingInfoTitle") as text | |
| set album to (infoDict's valueForKey:"kMRMediaRemoteNowPlayingInfoAlbum") as text | |
| set artist to (infoDict's valueForKey:"kMRMediaRemoteNowPlayingInfoArtist") as text | |
| return title & " - " & album & " - " & artist & " | " & appName | |
| end run |
To anyone stumbling upon this, looking for a solution to use the MediaRemote framework in its full capacity, I found a solution to load it on all versions of macOS, including 15.4 and above: https://github.com/ungive/mediaremote-adapter
@SKaplanOfficial thank you for the answer. Btw do you know why browsers elapsed time doesn't update?
@Pen7art Check this for why elapsed time appears as not being updated: ungive/mediaremote-adapter#6
@SKaplanOfficial - wasn't able to reproduce the command functionality on macOS 26.1. Reading media works, however writing to the media client seems to be blocked. Can anyone else confirm?
@ejbills Commands (play, pause, etc.) work for me on the 26.2 beta, tested with built-in apps, Spotify, and YouTube. I can't easily test on 26.1 at this point, but if there was a bug, it seems to be fixed.
@starsea Like this:
or in JXA: