MTMR icon indicating copy to clipboard operation
MTMR copied to clipboard

Now playing would catch all music apps

Open Suplanus opened this issue 5 years ago • 1 comments

When we use the now playing info, all music apps which provide data in the notification player would be shown in the touchbar. More information: https://stackoverflow.com/questions/61574238/swift-macos-retrieving-track-title-and-artist-of-currently-playing-music

Suplanus avatar Dec 01 '20 07:12 Suplanus

I've managed to get this info from Now Playing widget in Notification Centre using Apple Script. But it has a big downside as the focus from current app gets lost every time the script executes.

tell application "System Events" to tell process "ControlCenter"
	set track to ""
	tell menu bar item "Now Playing" of menu bar 1 to click
	tell group 1 of window "Control Centre"
		repeat with i from 1 to (count UI elements)
			if (name of UI element i = "pause") then set track to name of UI element (i - 1)
		end repeat
	end tell
	tell menu bar item "Now Playing" of menu bar 1 to click
	track
end tell

fedyakov avatar Jan 18 '21 20:01 fedyakov