5

I was using this answer for how to fade out music player volume in my app, but in iOS 5, this leads to the on-screen HUD for volume appearing to the user, as if they had pressed the volume buttons on the side of their device. Does anyone know a workaround that doesn't display the HUD?

enter image description here

Community
  • 1
  • 1
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92
  • Have you resolved this issue yet? I am also experiencing the same issue. For now I have just disabled fading of the music player, however you can't really hear the sound alert. – Luke Oct 28 '11 at 03:05
  • Still haven't figured it out - I just don't fade out the music on iOS 5. – Ash Furrow Oct 29 '11 at 23:59

1 Answers1

4

I found a solution here: applicationMusicPlayer volume notification

It simply directs you to add an MPVolumeView to your view. For some reason, having that in the view hierarchy prevents the volume HUD from appearing. Works for me, hopefully for you too.

Community
  • 1
  • 1
kurtzmarc
  • 3,110
  • 1
  • 24
  • 40
  • 1
    ATTENTION: I had a problem with this showing the AirPlay icon, even in a CGRectZero, which did not happen during testing because there were no AirPlay devices on our wifi network. You need to set volumeView.showsRouteButton = NO; – Ash Furrow Nov 04 '11 at 15:43
  • Or just hide the MPVolumeView somewhere in your view hierarchy. I have not checked the effect of setting "hidden" on the MPVolumeView to true, or of setting the MPVolumeView to an offscreen frame - I suspect those would be very easy checks which the system MIGHT be using to check and decide if the HUD needs to be shown or not. (it needs some ways of deciding WHEN to show the HUD and when not to, for example if an MPVolumeView is added to a view which is currently offscreen or earlier in the nav hierarchy, the user SHOULD see the HUD) – Dev Kanchen Jan 25 '12 at 18:21
  • Is this a method that would be deemed acceptable by Apple? Has anyone used it in an app they've had approved? – sooper Mar 17 '12 at 01:00
  • I've used it, and there was no problem. I highly doubt there would be as it is not using any private APIs or doing any trickery. This may in fact be the appropriate solution. – kurtzmarc Mar 17 '12 at 23:29