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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:53:49+00:00 2026-05-27T18:53:49+00:00

I am implementing some video into my iPad app and its works fine. But

  • 0

I am implementing some video into my iPad app and its works fine. But the issue I am running into is that when I leave the view to navigate somewhere else the video audio keeps playing in the background. Is there a way to completely stop the video and remove it from the view before closing the view?

I tried:

[moviePlayerController stop]; – But that does not seem to stop the movie it just crashes the app.

[moviePlayerController.view removeFromSuperview]; – That removes the video from the view but does not stop the audio.

This is what I have for the code:

- (IBAction)PlayMediaButton:(id)sender
{   

[moviePlayerController stop];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) 
                                             name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

NSString *movpath = [[NSBundle mainBundle] pathForResource:@"albert" ofType:@"mp4"];
MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc] 
                                                 initWithContentURL:[NSURL fileURLWithPath:movpath]];

if ([[NSFileManager defaultManager] fileExistsAtPath:movpath])      //Does file exist?
{
    moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:movpath]];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlaybackComplete:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayerController];  

    moviePlayerController.view.frame = CGRectMake(38, 37, 986, 618);
    [self.view addSubview:moviePlayerController.view];
    [moviePlayerController play];

    if ([moviePlayerController respondsToSelector:@selector(setAllowsAirPlay:)])    //Allow airplay if availabe
        [moviePlayerController setAllowsAirPlay:YES];

    [moviePlayerController play];

}            
}



- (void)moviePlaybackComplete:(NSNotification *)notification
{
    MPMoviePlayerController *moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:moviePlayerController];

    [moviePlayerController.view removeFromSuperview];
    [moviePlayerController release];
}
  • 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-27T18:53:50+00:00Added an answer on May 27, 2026 at 6:53 pm

    If I’m following you correctly, you should stop the movie player controller in -viewWillDisappear:.

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
        [moviePlayerController stop];
    }
    

    Edit Just noticed that you’re creating a MPMoviePlayerViewController instead of an MPMoviePlayerController. The former is meant to be displayed modally since it as a subclass of UIViewController. This explains the crash because MPMoviePlayerViewController doesn’t respond to a -stop message. So either, display moviePlayerController with -presentModalViewController:animated: or change it’s type to MPMoviePlayerController and add it to your view as you are doing now.

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

Sidebar

Related Questions

I'm implementing some basic ranking functionality in my MVC application, but I'm running across
While implementing some security aspects with Spring Security, I have noticed that both Authentication
I am implementing some networking stuff in our project. It has been decided that
in a bash script I am implementing some functions, that take parameters The problem
I had some troubles implementing Lawler's algorithm but thanks to SO and a bounty
I'm implementing some affiliate tracking to my site. The affiliate network has asked that
Im Implementing a video broadcasting website. For that I planned to use silverlight player
I am not much into gaming but i am learning and doing some practicles
This has been asked before , but even after implementing that solution, problems remain.
Im implementing some rostering app for the iphone, it uses coredata to save the

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.