Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:01:22+00:00 2026-06-13T19:01:22+00:00

I have VideoController which plays video. Now VideoController is pushed in navigationController . VideoController

  • 0

I have VideoController which plays video. Now VideoController is pushed in navigationController.

 VideoController *ObjVideoController = [[VideoController alloc] init];
 ObjVideoController.strVideoURL = [AnimationArr objectAtIndex:SequenceCount];
 [self.navigationController pushViewController:ObjVideoController animated:NO];
 [ObjVideoController play:[AnimationArr objectAtIndex:SequenceCount]];

Play method in VideoController is like this:

 - (void)play:(NSString*)videoFile {
    playbaktime = 0.0;

    NSBundle *main = [NSBundle mainBundle];
    NSURL *url = [NSURL fileURLWithPath:[[main resourcePath] stringByAppendingPathComponent:videoFile]];

    if (!self.ctl)
    {
        self.ctl = nil;
        self.ctl = [[MPMoviePlayerController alloc]init];
        [self.view addSubview:self.ctl.view];
    }
    [self.ctl prepareToPlay];
    self.ctl.contentURL = url;
    self.ctl.controlStyle = 0;
    //self.ctl.useApplicationAudioSession = NO;
    [self.ctl.view setUserInteractionEnabled:NO];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        [self.ctl.view setFrame:CGRectMake(0,0,480,320)];
    else
        [self.ctl.view setFrame:CGRectMake(0,0,1024,768)];

    self.ctl.backgroundView.backgroundColor = [UIColor whiteColor];
    [self.ctl play];
}

Now observer has been add for UIApplicationWillResignActive, UIApplicationDidBecomeActive. Its selector are given below:

 -(void)Pause_Video:(NSNotification*)notification {
   Pausevideo = 1;
   playbaktime = self.ctl.currentPlaybackTime;
   [self.ctl pause];
 }

-(void)Play_Video:(NSNotification*)notification {

  if(self.ctl.loadState == MPMovieLoadStateUnknown)
  {
    [self play:self.strVideoURL];
    Pausevideo = 0;
  }
  else{
    if (self.ctl.playbackState == MPMoviePlaybackStatePaused) {
        [self.ctl play];
        Pausevideo = 0;
    } 
    else
    {
        [self.ctl setInitialPlaybackTime:playbaktime];
        [self.ctl play];
        Pausevideo = 0;
    }
   }  
  }

Hope u understood question and help will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:01:23+00:00Added an answer on June 13, 2026 at 7:01 pm

    You seem to be calling prepareToPlay every time before playing, this is not necessary, just call it once when you load the file. There is no need to call it after you pause.

    Additionally, you are incurring a lag because notifications do not fire instantly. Specifically, UIApplicationDidBecomeActive only fires well after the app has entered the foreground. What you want instead is to observe the UIApplicationWillEnterForegroundNotification, which will fire as the app is entering the foreground, and allow you to decrease the lag significantly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ViewController which is pushed onto the NavigationController stack. As soon as
I have a ViewController which creates a NavigationController and puts a UIView in it.
I have a viewcontroller in which I wanted it to be presented only in
I have a ViewController on which there is a UITextView. On swipe let/right i
So I have a ViewController Class which is my first view, I then add
This is more of a design question. I have a single ViewController which manages
I have a local property which is an IBOutlet to a WebView in the
In my app I have a viewcontroller which is the delegate of NSFetchedResultsController and
On my storyboard (shown above), I have a ViewController which holds an MKMapView with
So I have an UIImageView which can be rotated about its center with touchesMoved.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.