iOS8 AVAudioSession setActive error

I solved this problem, inserting this code in the method of AVAudioPlayerDelegate.

-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{
  [audioPlayer stop];
  [audioPlayer prepareToPlay];
}

where audioPlayer is a variable declared in the header of my class.

the instruction prepareToPlay should resolve your problem!


Be warned. If you are playing a movie (even with no sound and the audio track removed) then it will still create an I/O thread which will always cause the above error to be thrown.