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!