0

I'm playing a video in iPad and stopping it using "Home" button on iPad. When i again start the video it should start from where it was stopped earlier and not from beginning. Can anyone tell me how do i do this?

To restart the video from beginning i used

- (void)applicationWillEnterForeground:(UIApplication *)application
    {
       NSLog(@"app enter foreground");
       PlayVideo *PVC=[[PlayVideo alloc] initWithNibName:@"PlayVideo" bundle:nil];
       self.window.rootViewController=PVC;     
    }
3
  • Are you overriding Home Button action? That could lead your app getting rejected. Jan 28, 2013 at 7:04
  • no i'm overriding "AppDelegate" method, to restart the app. But i want it to begin from where it was stopped.
    – Ankita
    Jan 28, 2013 at 7:17
  • When you put app in background just pause the video and play it again when you come back. Jan 28, 2013 at 8:31

1 Answer 1

0

Use this method to listen the state change of videoplayer.

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(playbackStateChanged) 
name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

In the applicationDidEnterBackground, capture the playback time. MPMoviePlayerController conforms to the MPMediaPlayback protocol, and does have a currentPlaybackTime property available. Save this playback in the NSUserDefaults or wherever u feel easy, for the next launch of app, i.e. in applicationDidiEnterForeground method resume playing from this playback time.

2
  • @Ankita: Did u got the result or not.. if yes do the favor of accepting the answer. Feb 25, 2013 at 10:40
  • i used applicationWillEnterForeground delegate method to resolve the issue.Therefore i did not try the method suggested by you, i shall try it let you know.Thnks
    – Ankita
    Feb 27, 2013 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.