Search code examples
iosavaudioplayer

iphone stop AVAudioPlayer


I want to stop the AVAudioPlayer when click on new tab. Stop an Pause button are working properly but if i am click on new tab bar the player is to be play in background so how can i stop the player.

I used:

-(void)stop_play
{
    [player stop];
    play.hidden=NO;
    stop.hidden=YES;
}

Solution

  • when you click on new tab,in your action method write code like this

    if(audioPlayer.playing){
    [audioPlayer stop];
    }