iOS: Missing audio routes/sources in MPVolumeView

2019-08-15 11:27发布

问题:

I work on an audio app (using audio units).
One of the requirements is to be able to change the audio route from the UI (Earpiece, Speaker, Connected Bluetooth device etc.).
I use the MPVolumeView for this.

Recently I have a bug with the list of routes that are displayed in the action sheet that is opened when tapping the route button in the volume view.
I think that the problem appears only in iOS6, but not sure about that.
The result is random:

  • sometimes it displays only iPhone
  • sometimes it displays iPhone twice instead of iPhone and Speaker (in this case usually the icon near both 'iPHone' buttons is like it is a speaker - TV icon)
  • sometimes it works good
  • the Bluetooth is always displayed good

Some additional info:
The volume view is initiated only in Play&Record audio category.
The volume view is initiated and added to the screen only after the user taps a corresponding button on the screen. This button becomes available only after the category is switched to Play&Record (it is not immediate, so I set a listener to the route transitions and enable the button only after the route is REALLY changed).

Screenshots:

If anyone has experienced this problem then please share a solution.

Thank you.

回答1:

I've seen this in the multitasking tray's route selection UI on my iPhone 4S and 5 running 6.0. I suspect it's an iOS bug.



回答2:

I have the same issue. What I've noticed is that it is related to the media currently being played. If it is not compatible with the Airplay / media device, then it does not appear in the list. For example, I want to play audio to a Bluetooth HFP device, which only supports 8Khz Audio. I've seen an app which modifies the audio to match the device, but don't know how they do that programmatically.