Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 941
subjective-c Avatar asked Dec 04 '25 08:12

subjective-c


2 Answers

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.

like image 78
Aleksandar Vacić Avatar answered Dec 06 '25 23:12

Aleksandar Vacić


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

like image 30
frankodwyer Avatar answered Dec 06 '25 22:12

frankodwyer