pause current music when audioplayer object kick in.

Dear all,


I am currently encountering an issue and looking for a solution to help me get out of this situation. The situation is that whenever the audioplayer object created, it pauses the current playing music from spotify, pandora..,etc.


Below is my sample code:

Inside .h

#import <AVFoundation/AVFoundation.h>

@interface testclass_view : UIViewController{


AVAudioPlayer *audioplayer;

}

inside .m

-(void)viewDidLoad{

NSString *songmp3 = [[NSBundle mainBundle] pathForResource:@"clicksound" ofType:@"wav”];

audioplayer = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:songmp3] error:NULL];

audioplayer.delegate=self;

audioplayer.numberOfLoops=0;

}


- (IBAction)pushbutton(id)sender {

[audioplayer play];

}

Thanks in advance!

See here:


https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/


for the various settings for your app that indicate how it interacts with other audio.

Thank you and I am done.

pause current music when audioplayer object kick in.
 
 
Q