When I connect my phone to my car radio, via Bluetooth, I can control apps I’m running.
For instance, I can answer calls, hang up calls, with the push of a button on my steering wheel.
Also, I can use the buttons on my steering wheel to skip through tracks on iTunes or the Spotify app.
I’m wondering if I can make my iOS app respond to these button presses. There must be a way. Other apps like iTunes and Spotify already make use of these buttons on my steering wheel.
Does anyone have a clue how to get these buttons working?
What exactly does your app do? If you have an audio app, then using the standard AVFoundation classes to play the audio should allow your app to use those audio control buttons just fine. If you are trying to “hijack” them to do something else within the app, I dont think you will have a lot of luck though. If you want to implement CarPlay for your app, that might be possible with declares, I’m not sure. It does seem likely youll run into issues due to not running on the main thread, however.
Thanks for the quick reply, Jason!
I’m not trying to hijack anything.
The reception of my car radio is terrible. So, I switch to several radio station apps. But, switching between these is annoying. Also, I would rather keep my hands on the wheel, and eyes on the road.
So, I was thinking to store a few live-streams in a database. And use the AV Player by MBS to play those streams. I was hoping to detect the next and previous buttons, to switch between the stations.
Playback worked, with the help of the MBS plugins. But I just don’t know how to get the buttons on my steering wheel working.
Ok, unless I’m reading this wrong, it looks to me like Apple doesn’t give you direct access to forward and back any more. It seems that Audio apps are expected to provide a list of media and CarPlay sends a notification to your app saying “play this item”. Now you might be able to figure out if the user pressed forward or back buttons based on what was last playing, but you should keep in mind that CarPlay provides several ways for an audio track to be played next, so they may not always be requested in a particular order.
The problem is that I don’t have CarPlay.
My radio is, I guess, just a generic Bluetooth device.
The radio on my nightstand is kind of the same thing. When connected, I can skip to the previous and next song. I can play, pause, etc.
Also, the display of both radios show the playing track.
When I open a radio station’s app the display will actually show metadata as well, like the name of the radio station, the name of the airing show.
Somehow, it must be possible to send that kind of data to my Bluetooth receiver right? I mean, there are plenty of apps out there, that already do this kind of stuff.