Play music in Apple Music App
I am looking for a way to specify an existing album from my Music app and start playing it.
Is this possible with Pythonista 3 on iOS 12?
I appreciate any ideas or solutions.
@weda82 Perhaps something like this
from objc_util import * def main(): MPMediaPropertyPredicate = ObjCClass('MPMediaPropertyPredicate') MPMediaPropertyPredicate.predicateWithValue_forProperty_('Songs of Innocence', 'albumTitle') MPMediaQuery = ObjCClass('MPMediaQuery').alloc().initWithFilterPredicates_((MPMediaPropertyPredicate,)) MPMusicPlayerController = ObjCClass('MPMusicPlayerController') player = MPMusicPlayerController.systemMusicPlayer() player.setQueueWithQuery_(MPMediaQuery) player.play() main()
The script starts to play but I'm not able to select songs...
Just a starting point 😢
Thank you for your ideas and I am sorry for my late reply.
I tried the previous suggestion and I think the query is not working properly. If I iterate the query result it returns all my media items. But I also do not see the problem. As far as I understood the Apple documentation, it looks correct to my.
I tried a different approach:
from objc_util import * def main(): NSBundle.bundleWithPath_( '/System/Library/Frameworks/MediaPlayer.framework').load() matchingItem = ["928428096"] # StoreId of "Songs of innocence" MPMusicPlayerController = ObjCClass('MPMusicPlayerController') player = MPMusicPlayerController.systemMusicPlayer() player.setQueueWithStoreIDs(matchingItem) player.play() main()
I got the StoreId from this web site:
This is working, but not as comfortable as I was looking for.