MusicKit play back with Mac Catalyst seems not be working.

I have be trying to use the sample code project associated with WWDC21 session 10294: Meet MusicKit for Swift, with Catalyst.

The apps works on mac correctly excepted the playback and the barcode scanning (that is out of my scope)

The following message is displayed continuously:

MusicAlbums[30849:533531] [SDKPlayback] Failed to obtain synchronousRemoteObject: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.Music.MPMusicPlayerApplicationControllerInternal was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.Music.MPMusicPlayerApplicationControllerInternal was invalidated: failed at lookup with error 3 - No such process.}

Before diving deeper i wanted to know if some of you have been able to play music via MusicKit with Mac catalyst?

The sample code uses an ApplicationMusicPlayer.shared that is not available directly on macOS. (In fact none of the Music players are available)

Would you recommend another approach to provide MusicKit playback on mac os ?

  • I filed feedback FB9851840 (including sample project) reporting this very issue just moments before seeing this post. I get the same error as you. The documentation page for MusicPlayer does not mention it is available in macOS, but says it is in Mac Catalyst 15.0+, so it's not clear what is supposed to work. Perhaps @JoeKun can shed some light on the expected behavior of this API? I am really hoping to bring my iOS music player to the Mac in the future.

Add a Comment

Accepted Reply

Hello @bpereiradasilva and @talking small,

Thank you very much for your feedback about issues with ApplicationMusicPlayer in a Mac Catalyst app.

Bringing ApplicationMusicPlayer and SystemMusicPlayer to macOS does present some significant engineering challenges for us, which is why we have yet to enable support for this API on macOS.

For Mac Catalyst specifically, our early tests of these APIs seemed promising, so we initially didn't see any reason to restrict availability of these APIs for that environment. But evidently, we need to keep investigating issues like the ones you have uncovered to make these APIs work reliably in Mac Catalyst apps.

We will keep investigating those issues.

Best regards,

  • Thanks for the clarification, Joe. Fingers crossed there will be some good news at this year's WWDC about being able to bring MusicKit apps to the Mac!

  • I discovered this purely by chance (and I shudder to think about what is going under the covers) but I found that if the following line of code gets run before the call to ApplicationMusicPlayer then it all seems to work: let _ = MPMediaQuery.playlists() Clearly this ought not to have any effect at all, but it works for me so I'm sharing it in case it works for others.

  • @dutton Yeah, I mean the whole thing is just so janky (apologies, @JoeJun I really appreciate your feedback a few months ago here, but computers have been reliably playing back music including DRM protected streams with excellent reliability since the 1990s so I'm really not sure how it can possibly be so hard to send some JSON API calls to and from a server and somehow have that whole thing fall in a heap) but your suggestion, astonishingly, did allow playback to begin.

    _________________ (sorry about <--- those but this forum doesn't respect paragraph breaks in comments (!) and that's the best I could do)

    My application gets no information back from queries during playback so it has no idea what the media duration was, or where the playhead is; it does at least get the playback state but that's about it. Worse, the Music app in macOS acted as if it was playing the track itself! So, not just a "now playing" application, but bizarrely a totally different application started reacting with notifications, history entries and even playback progress. So while my app using the official API from Apple was unable to get playback position, somehow a totally unrelated application had access.

    _________________

    I don't understand why there isn't a native macOS API for this; there are only iOS examples out there, none of the docs talk about macOS, nobody's written a 3rd party client... So all we've got is Catalyst as far as I can see and I don't understand why it's still such a mess. I just don't understand why the API still says things like "failed to prepare to play" on any platform after so many years. There are so many aspects of this that just make no sense. How is this possible? It's just music playback! I've written head-ends for VOD systems myself that did this and more with full server-side trick play over protocols like RTSP and it really just was not hard - and that was well over a decade ago. Meanwhile other music services like Spotify just work.

    _________________

    I'm just so bemused, depressed and fed up by this. The developer experience on all platforms is just awful.

    _________________

    Is there any update? Is there any hope? Has there been progress in the last 3 months on making at least a Catalyst option for music playback work?

    _________________

    I'm not intending to shoot the messenger here, but Apple is one of the richest companies on earth and has essentially unbounded engineering resource. I just can't figure out how this situation can have arose. Is there actually just no corporate interest at all in making this work? Does Apple simply not care about any 3rd party developers for their music service?

    Sigh. Sorry. But this whole thing is just so incredibly sad :-(

Replies

Hello @bpereiradasilva and @talking small,

Thank you very much for your feedback about issues with ApplicationMusicPlayer in a Mac Catalyst app.

Bringing ApplicationMusicPlayer and SystemMusicPlayer to macOS does present some significant engineering challenges for us, which is why we have yet to enable support for this API on macOS.

For Mac Catalyst specifically, our early tests of these APIs seemed promising, so we initially didn't see any reason to restrict availability of these APIs for that environment. But evidently, we need to keep investigating issues like the ones you have uncovered to make these APIs work reliably in Mac Catalyst apps.

We will keep investigating those issues.

Best regards,

  • Thanks for the clarification, Joe. Fingers crossed there will be some good news at this year's WWDC about being able to bring MusicKit apps to the Mac!

  • I discovered this purely by chance (and I shudder to think about what is going under the covers) but I found that if the following line of code gets run before the call to ApplicationMusicPlayer then it all seems to work: let _ = MPMediaQuery.playlists() Clearly this ought not to have any effect at all, but it works for me so I'm sharing it in case it works for others.

  • @dutton Yeah, I mean the whole thing is just so janky (apologies, @JoeJun I really appreciate your feedback a few months ago here, but computers have been reliably playing back music including DRM protected streams with excellent reliability since the 1990s so I'm really not sure how it can possibly be so hard to send some JSON API calls to and from a server and somehow have that whole thing fall in a heap) but your suggestion, astonishingly, did allow playback to begin.

    _________________ (sorry about <--- those but this forum doesn't respect paragraph breaks in comments (!) and that's the best I could do)

    My application gets no information back from queries during playback so it has no idea what the media duration was, or where the playhead is; it does at least get the playback state but that's about it. Worse, the Music app in macOS acted as if it was playing the track itself! So, not just a "now playing" application, but bizarrely a totally different application started reacting with notifications, history entries and even playback progress. So while my app using the official API from Apple was unable to get playback position, somehow a totally unrelated application had access.

    _________________

    I don't understand why there isn't a native macOS API for this; there are only iOS examples out there, none of the docs talk about macOS, nobody's written a 3rd party client... So all we've got is Catalyst as far as I can see and I don't understand why it's still such a mess. I just don't understand why the API still says things like "failed to prepare to play" on any platform after so many years. There are so many aspects of this that just make no sense. How is this possible? It's just music playback! I've written head-ends for VOD systems myself that did this and more with full server-side trick play over protocols like RTSP and it really just was not hard - and that was well over a decade ago. Meanwhile other music services like Spotify just work.

    _________________

    I'm just so bemused, depressed and fed up by this. The developer experience on all platforms is just awful.

    _________________

    Is there any update? Is there any hope? Has there been progress in the last 3 months on making at least a Catalyst option for music playback work?

    _________________

    I'm not intending to shoot the messenger here, but Apple is one of the richest companies on earth and has essentially unbounded engineering resource. I just can't figure out how this situation can have arose. Is there actually just no corporate interest at all in making this work? Does Apple simply not care about any 3rd party developers for their music service?

    Sigh. Sorry. But this whole thing is just so incredibly sad :-(

Joe - what are we supposed to use for playback in a Mac app? This seems like something that should be called out in an overview or intro doc.

  • @dimsumthinking I m currently testing an approach that replicates music kit JS behavior with an AVAudioPlayer. It will not integrate with the System or App player, but it should not be very complex to implement. The Mac catalyst version is more deeply integrated and i don't think it will be available soon.

  • I've managed to use MusicKit JS inside a WKWebView for playback. I wrote a small script that loads and configures MusicKit JS and attaches some functions like play/skip etc. to the window object to be called from Swift using webview methods. Events from player can also be sent back to Swift code using WKScriptMessageHandler.

Add a Comment

Hello @dimsumthinking,

At the moment, we don't have any better answer than the one I've already given.

We will keep investigating these issues with MusicKit's playback APIs on macOS.

Best regards,

  • @JoeKun it seems to me, at the very least, that the docs for ApplicationMusicPlayer should be updated to indicate that the player is NOT supported on Mac Catalyst 15+ contrary to what is indicated in the docs.FB12137389

Add a Comment

Is there still no update on this seven months later?

  • Apparently not. If they not announce it on September event than we are left behind for good, and that means we must all slowly migrate to Spotify

Add a Comment

So here we are, another year goes by, another new operating system release and no fix.

Apple have abandoned developers for Music; the API where implemented is incredibly unreliable with basic design frustrations all over it, while the vendor-provided applications are rife with bugs and bewildering, inconsistent UI design and navigation choices.

Apple doesn't care.

I'm abandoning Apple Music in all application development from this point and moving it to Spotify, and will be recommending Spotify as a preferred service henceforth.