Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Play music in Apple Music App
-
Hello
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.
Thank you
-
@weda82, in docs for the
objc_util
module there is an example for accessing currently-playing song info. Probably you could expand from that with the help of Apple documentation. -
@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:
https://linkmaker.itunes.apple.com/de-deThis is working, but not as comfortable as I was looking for.
-
@weda82 👍
-
Thanks for sharing, but that seems not working anymore. I use the Tunelf Audio Converter to get Music songs down and the quality is still quite good.
-
This post is deleted! -
This post is deleted! -
This post is deleted!