Why doesn't my iPod sound fade after my app makes it fade?

My application needs to play some audio files, and I want to make an iPod sound, play my file, and then as soon as my sound stops playing iPod again (just like the iPhone handles iPod music when an incoming call arrives)

I configure my Audio Session application as kAudioSessionCategory_MediaPlayback, and then before playing my file, I call AudioSessionSetActive (true) then when my file ends, I call AudioSessionSetActive (false)

What happens is that the iPod sound fades out with an call to AudioSessionSetActive (true), but it never fades out after I call AudioSessionSetActive (false)

I use the AVFoundation class to play my audio, I have audioPlayerDidFinishPlaying in my delegate method and where I call AudioSessionSetActive (false).

What am I missing here? Why doesn't the iPod disappear when I deactivate my audio session? Do I have the wrong category of audio sessions for this?

+1
source share
2 answers

I received an answer from Apple about this. Unfortunately, with SDK 2.2 this is not possible. I sent a function request, so who knows, maybe it will add this functionality in the future.

+2
source

Ok, that's fine. On iPhone OS3, see AddMusic Example.

Essentially, you do this:

#import <MediaPlayer/MediaPlayer.h>
...
[[MPMusicPlayerController iPodMusicPlayer] pause]
...(play your audio, with AmbientSound category)
[[MPMusicPlayerController iPodMusicPlayer] play]

This is the main thing. You can also add fadeout by cyclically changing the volume, etc.

+4

All Articles