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 3988524
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:15:45+00:00 2026-05-20T06:15:45+00:00

I am trying to get an embedded video playback properly implemented within a tab-bar

  • 0

I am trying to get an embedded video playback properly implemented within a tab-bar navigation. In my specific case, the video shall be displayed in a non-fullscreen manner on a UIView that is hosted by a UIViewController, managed by a UITabBarController.

For simplifying the example, lets say I have two tabs within my tabbar. First one shows some random stuff, second one shows the viewcontroller that hosts the embedded video.

Once the user selects the second tab, the video is loading and playing properly.

For initializing the player, I am using the following code from within my UIView derived class, triggered by the initializer (initWithFrame):

- (void)initPlayback
{
     self.movieViewController = [[MPMoviePlayerViewController alloc] init];
     movieViewController_.wantsFullScreenLayout = NO;
     movieViewController_.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
     [self addSubview:self.movieViewController.view];
}

For starting the playback, I am using the following code, triggered by the viewWillAppear method of my UIViewController derived class:

- (void)playVideo
{
     [movieViewController_.moviePlayer setContentURL:fileURL_];
}

If then, the user selects the first tab (while the video is still playing), I am making sure that the video is stopped as it would continue playing if that was not done:

- (void)stopVideo
{
     [movieViewController_.moviePlayer stop];
}

Once the user selects the second tab again, the view stays blank, nothing is loaded or played even though the playVideo-method is invoked.

What am I missing, why is the video playback failing when reselecting the second tab?

==========new attempt=============

This time I stopped relying on shouldAutoplay (as suggested) but that did not make a difference.

Adapted and added code for this;

- (void)MPMoviePlayerLoadStateDidChange:(NSNotification *)notification
{
    if (movieViewController_.moviePlayer.loadState == MPMovieLoadStatePlayable &&
        movieViewController_.moviePlayer.playbackState != MPMoviePlaybackStatePlaying)
    {
        [movieViewController_.moviePlayer play];
    }
}

- (void)deregisterFromNotifications
{
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerLoadStateDidChangeNotification 
                                                  object:nil];

}


- (void)registerForNotifications
{
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(MPMoviePlayerLoadStateDidChange:) 
                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                               object:nil];
}

- (void)initPlayback
{
    NSLog(@"playback init...");
    self.movieViewController = [[MPMoviePlayerViewController alloc] init];
    movieViewController_.wantsFullScreenLayout = NO;
    movieViewController_.moviePlayer.shouldAutoplay = NO;
    movieViewController_.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
    movieViewController_.moviePlayer.currentPlaybackTime = 0.0f;
    [self addSubview:movieViewController_.view];
}

- (void)playVideo
{
    NSLog(@"playback starting...");
    [self registerForNotifications];
    [movieViewController_.moviePlayer setContentURL:fileURL_];
}

- (void)stopVideo
{
    NSLog(@"playback stopping...");
    [movieViewController_.moviePlayer stop];
    [self deregisterFromNotifications];
}
  • 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-05-20T06:15:46+00:00Added an answer on May 20, 2026 at 6:15 am

    Adding [movieViewController_.moviePlayer prepareToPlay] to my playVideo method does the trick (when working with remote streams).

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

Sidebar

Related Questions

I'm trying to launch embedded Youtube videos from a UIWebView, but get this error
Hey folks. Trying to get started with iPhone video capture stuff, and having a
I'm trying to get started with embedded linux Qt Development, and I've built Qt
I am trying to get a winform app to refresh an embedded browser on
I'm using the GCal4Ruby gems plugin. I'm trying to get it render an embedded
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get my css / C# functions to look like this: body {
Trying to get an ASP application deployed; it worked for a while but then
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Whilst trying to get our app working in Firefox (I'm a big proponent of

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.