Search Results

Search found 1 results on 1 pages for 'swastik'.

Page 1/1 | 1 

  • Audio File continues to play even on leaving the view

    - by Swastik
    What I am doing is -(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]; } Now, on pushing another view this audio file keeps playing in the background. Please help!

    Read the article

1