0

I'm using AVAudioPlayer in my iPhone app and it runs fine. I play an MP3 when in the viewWillAppear and stop it in viewWillDisappear. When I call [player stop] the sound is stopped immediately, is there a way to stop the sound slowly, as it happens when the user closes the app while the sound is still playing?

iknow
  • 8,358
  • 12
  • 41
  • 68
Cris
  • 12,124
  • 27
  • 92
  • 159
  • Hi Cris, you can simple use the function in this [post](http://stackoverflow.com/a/1667535/1195661) by bdebeez. – palme Feb 04 '14 at 17:26

1 Answers1

0

You could slowly lower to volume until it reaches 0. To do so you need a timer to fire off every 0.01 seconds, inside the void insert this

player.volume = player.volume - 0.01;

Now the audio slowly fades out!

Allison
  • 2,213
  • 4
  • 32
  • 56