2011-01-13 64 views
2

我在做什麼是音頻文件,甚至繼續在​​離開視圖中播放

-(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]; 

} 

現在,在推動另一種觀點認爲此音頻文件保存在後臺播放。 請幫忙!

回答

3

那麼它是非常常見的錯誤

當你留在你使用

+0

以及感謝播放音頻@ robin.I你之前固定的問題AVAudioPlayer指針變量視圖通話停止方法同樣回答 – Swastik 2011-01-13 04:41:08

相關問題