音频文件,甚至继续在​​离开视图中播放

问题描述:

我在做什么是音频文件,甚至继续在​​离开视图中播放

-(void)viewWillAppear:(BOOL)animated{ 

[NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(clickEvent:) userInfo:nil repeats:YES]; 
} 

-(void)clickEvent:(NSTimer *)aTimer{ 

NSDate* finishDate = [NSDate date]; 

if([finishDate timeIntervalSinceDate: self.startDate] > 11 && touched == NO){ 

    NSString *mp3Path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"test.mp3"]; 
    [self playMusicFile:mp3Path]; 
    NSLog(@"Timer from First Page"); 
    [aTimer invalidate]; 
    //[touchCheckTimer release]; 
    aTimer = nil; 

} 

else{ 


} 

-(void)playMusicFile:(NSString *)mp3Path{ 

NSURL *mp3Url = [NSURL fileURLWithPath:mp3Path]; 
NSError *err; 
AVAudioPlayer *audPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:mp3Url error:&err]; 
[self setAudioPlayer1:audPlayer]; 
if(audioPlayer1) 
    [audioPlayer1 play]; 

[audPlayer release]; 

} 

现在,在推动另一种观点认为此音频文件保存在后台播放。 请帮忙!

那么它是非常常见的错误

当你留在你使用

+0

以及感谢播放音频@ robin.I你之前固定的问题AVAudioPlayer指针变量视图通话停止方法同样回答 – Swastik 2011-01-13 04:41:08