Use remote commands (Control Center) with custom audio app

I have a music-making app that generates audio using an AUSampler. I want to make it so that you can control playback while the app is in the background using the play/pause controls in Control Center.


I've set up handler blocks on MPRemoteCommandCenter and I'm providing info to MPNowPlayingInfoCenter, but nothing shows up in control center or the lock screen (it's just blank, or shows the last played song from Music, for example).


I believe I need to somehow indicate to the system that my app is the "Now Playing" app, but I'm not sure how to do that. I tried playing a silent .wav file in an AVPlayer but that didn't seem to do anything. Is it possible to use those controls to control arbitrary audio/media, or are they only available when playing something from the Music library?

Answered by jayson in 131036022

I figured out the issue - my app had AVAudioSessionCategoryOptionMixWithOthers set since I was also working on implementing Inter-App Audio. It makes sense, then, that your app can't become the "Now Playing" app if it's explicity said it wants to run alongside other audio.

Accepted Answer

I figured out the issue - my app had AVAudioSessionCategoryOptionMixWithOthers set since I was also working on implementing Inter-App Audio. It makes sense, then, that your app can't become the "Now Playing" app if it's explicity said it wants to run alongside other audio.

Use remote commands (Control Center) with custom audio app
 
 
Q