Read media now playing title for NON-apple system media player
Hi! I’ve been trying to find a way to programmatically read the title of the currently playing media in iOS - but not the track playing in Apple Music (this can already be done using Shortcuts).
I’ve tried all sorts of permutations from the apple developer docs, and other code snippets I’ve found on GitHub, but I can only seem to access the track playing in Apple Music app… rather than the track playing in audible, the files app or other media player apps like VLC for example.
The following seems to work for Apple Music:
from objc_util import * MPController = ObjCClass('MPMusicPlayerController') player = MPController.systemMusicPlayer() iplayer = MPController.iPodMusicPlayer() aplayer = MPController.applicationMusicPlayer() nowPlaying = player.nowPlayingItem() print((player.nowPlayingItem()).item().title()) print((iplayer.nowPlayingItem()).item().title()) print((aplayer.nowPlayingItem()).item().title())
It’s just the media title I want to extract, but info on the position in the media would be very useful to have.
Would really appreciate any pointers here as have been poking around for ages haha not familiar enough the porting swift/apple docs to Python yet 😄
What do you get when you try
That is the time, in seconds. There is a way to get duration, in order to calculate time remaining.