Monday, March 7, 2011

How can I lower the volume of iPod audio while my app plays a sound

I'm trying to reproduce the functionality of built-in Mail application when a new message arrives while you are listening to iPod music.

What happens with the Mail app is:

  1. iPod's volume lowers a bit
  2. Mail app plays a short sound and vibration
  3. iPod's volume goes back to normal

I know how to play a sound and cause vibration, what I don't know is how to lower iPod's volume and restore it after my sound plays.

How can I reproduce this same functionality in my app with SDK 2.2? I know third party apps can't run in the background. My users will play the iPod then have my app in the foreground.

From stackoverflow
  • Have you tried simply playing the sound? I suspect this is automatic functionality on the part of the SDK.

    edit: according to this question, you can fade the ipod sound out but not back in.

    (I'm surprised this functionality isn't automatic and default behaviour. But then I've always found the elegance of the apple APIs to be inversely proportional to the elegance of the interface :-)

    subjective-c : Yes, that's what I'm doing right now. The iPod's volume doesn't change.
    subjective-c : Yeah, I posted that question. I originally wanted to fade out/in iPod, but since that's not possible I though maybe I can just lover the volume just like the Mail app does. Can't agree more with you last statement :)
  • This is not possible with iPhone SDK 2.2.1 or earlier. If you need this functionality please submit a bug to apple. I've submitted one but duplicates indicate interest so it might help promote this issue.

  • See my answer to that other question of yours ;)

    [[MPMusicPlayerController iPodMusicPlayer] setVolume:x.y]
    

    where you change x.y through a timer or as one-off. In OS3, of course.

0 comments:

Post a Comment