Ios AVAudioPlayer超过2种声音
所以我试着让这里提供的所有向导同时播放AVAudioplayer+AVA,AVA+系统声音的2种声音,但都不起作用。 第二声永远不会响 所以我决定在播放2之前停止主音频。音频(铃声音频) 但它没有起作用 我需要在同一时间播放2个声音,或者在播放1个声音时播放。音频将暂停。(我的h文件中有委托) 下面是代码,NSTimer每0.5秒调用一次此方法:Ios AVAudioPlayer超过2种声音,ios,objective-c,avaudioplayer,Ios,Objective C,Avaudioplayer,所以我试着让这里提供的所有向导同时播放AVAudioplayer+AVA,AVA+系统声音的2种声音,但都不起作用。 第二声永远不会响 所以我决定在播放2之前停止主音频。音频(铃声音频) 但它没有起作用 我需要在同一时间播放2个声音,或者在播放1个声音时播放。音频将暂停。(我的h文件中有委托) 下面是代码,NSTimer每0.5秒调用一次此方法: if(!(bellint == -0.5)){ bellint = bellint+0.5; } if(!(self.loaderAudioV
if(!(bellint == -0.5)){
bellint = bellint+0.5;
}
if(!(self.loaderAudioView.fakeDuration == secondsTime)){
secondsTime = secondsTime +0.5;
self.loaderAudioView.fakeTimer = secondsTime ;
NSLog(@"fakedur %f , secondsOfTimer : %f" ,self.loaderAudioView.fakeTimer,secondsTime);
}
else{
self.loaderAudioView.fakeTimer = secondsTime = 0 ;
[self.timer invalidate];
self.playOrPauseButton.on = NO;
}
if((int)secondsTime % self.bellsInt == 0.0){
[self.loaderAudioView pausePlayer];
bellint = bellint+0.5;
NSURL *path = [[NSBundle mainBundle] URLForResource:@"bell_start" withExtension:@"mp3"];
// I've putted here AVAudioplayer initialization cause you can see. It's in another method realized.Here I just call [objAudio play];
AVAudioPlayer* objAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:path error:nil];
objAudio.delegate = self;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[objAudio prepareToPlay];
[objAudio play];
NSLog(@"BANG");
}
if(bellint == 5.0){
[self.loaderAudioView playPlayer];
bellint = -0.5;
}
所以在我把objAudio放到h文件并初始化之后
self.objAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:path error:nil];
一切都变成了应有的样子
我不知道为什么它不是那样工作的。
这是错误还是有某种原因。
如果有人知道原因或有一个理论,我欢迎。所以在我将objAudio放入h文件并初始化之后
self.objAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:path error:nil];
一切都变成了应有的样子
我不知道为什么它不是那样工作的。
这是错误还是有某种原因。
如果有人知道原因或有理论,我欢迎