views:

828

answers:

3

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.

+1  A: 

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 :-)

frankodwyer
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 :)
subjective-c
A: 

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.

subjective-c
+3  A: 

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.

Aleksandar Vacic