Note that there are some explanatory texts on larger screens.

plurals
  1. POpause button when pressed again to resume reloading view controllers
    primarykey
    data
    text
    <p>I am using <code>AVAudioplayer</code> to <strong>play audio files</strong>, <strong>play/pause button to toggle between play and pause</strong> and <code>NSTimer</code> with <code>audio player</code> to synchronize <code>view controllers</code> one after another. I have a total of 10 or 11 <code>view controllers</code> to load one after the other.</p> <p>When play button is pressed the very first time it starts <code>NSTimer</code>, starts playing an <code>audio file</code> and based on <code>NSTimer</code>, view controllers will load one after the other. When pause button is pressed again to resume it resumes everything from that point audio file, <code>NSTimer</code> and <code>view controllers</code> from the same point where it was paused which is good. However, at the same time it starts loading the <code>view controllers</code> again one after the other from the beginning based on <code>NSTimer</code> which is not good. </p> <p>It is reloading view controllers with this statement</p> <pre><code>self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(displayviewsAction:) userInfo:nil repeats:NO]; </code></pre> <p>So my issue is that I need to stop the loading of <code>view controllers</code> again from the beginning when pause button is pressed again to resume playback.</p> <pre><code>-(void)playpauseAction:(id)sender { if ([audioPlayer isPlaying]) { [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected]; [audioPlayer pause]; [self pauseTimer]; } else { [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal]; [audioPlayer play]; [self resumeTimer]; self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(displayviewsAction:) userInfo:nil repeats:NO]; } } -(void)pauseTimer{ pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain]; previousFireDate = [[timer fireDate] retain]; [timer setFireDate:[NSDate distantFuture]]; } -(void)resumeTimer{ float pauseTime = -1*[pauseStart timeIntervalSinceNow]; [timer setFireDate:[previousFireDate initWithTimeInterval:pauseTime sinceDate:previousFireDate]]; [pauseStart release]; [previousFireDate release]; } - (void)displayviewsAction:(id)sender { First *firstController = [[First alloc] init]; firstController.view.frame = CGRectMake(0, 0, 320, 480); CATransition *transitionAnimation = [CATransition animation]; [transitionAnimation setDuration:1]; [transitionAnimation setType:kCATransitionFade]; [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; [self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade]; [self.view addSubview:firstController.view]; [self.view addSubview:toolbar]; [firstController release]; self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO]; } </code></pre> <p>Can anyone give an idea on how to stop the loading of <code>view controllers</code> again from the beginning when pause button is pressed again to resume playback.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload