音頻播放器工作正常,如果我開始它20到30倍,但之後它顯示了以下錯誤AVAudioPlayer - >不工作
錯誤域= NSOSStatusErrorDomain代碼= -43「的操作無法完成。 (OSStatus錯誤-43)」
的代碼目前我使用的是如下
- (void)playShortSound:(NSString *)fileName type:(NSString *)type
{
if (!isSound) {
return;
}
NSString *soundFilePath =[[NSBundle mainBundle] pathForResource: fileName ofType: type];
NSURL *fileURL = [[[NSURL alloc] initFileURLWithPath: soundFilePath] autorelease];
NSError *error;
AVAudioPlayer *newPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL: fileURL
error: &error];
//newPlayer.numberOfLoops = 0;
newPlayer.volume=1.0;
if (newPlayer == nil){
NSLog(@"%@",[error description]);
//[self playShortSound:fileName type:type];
//return;
}
else{
[newPlayer play];
newPlayer.delegate=self;
}
}
- (void) audioPlayerDidFinishPlaying: (AVAudioPlayer *) player
successfully: (BOOL) completed {
if (completed == YES) {
NSLog(@"Sound Playing complete");
}else {
NSLog(@"error in completion of %@",player.url);
}
}
是的,這可能是一個可能的原因,但如果我嘗試釋放newPlayer;它不會播放聲音.... – Zahur 2011-03-19 04:51:43