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

  • SEARCH
  • Home
  • 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 7580669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:58:29+00:00 2026-05-30T17:58:29+00:00

Well i’m designing an iPhone app which will play video locally. When I click

  • 0

Well i’m designing an iPhone app which will play video locally. When I click the button in the simulator it plays perfectly but when it stops or when I end it manually it crashed and keeps giving me that problem.. I tried clean, build, analyse and run again but still the same. Any help?

My code is that:

MoviePlayerViewController.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>

@interface MoviePlayerViewController : UIViewController {

}
-(IBAction)playMovie:(id)sender;
@end

and the main bit in MoviePlayerViewController.m

- (IBAction)playMovie:(id)sender {
    NSString *movpath = [[NSBundle mainBundle] pathForResource:@"think" ofType:@"mp4"];
    MPMoviePlayerViewController *mpviewController = [[MPMoviePlayerViewController alloc]
                                                     initWithContentURL:[NSURL fileURLWithPath:movpath]];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

    [self.view addSubview:mpviewController.view];
    MPMoviePlayerController *mp = [mpviewController moviePlayer];
    [mp prepareToPlay];
    mp.scalingMode=MPMovieScalingModeAspectFill;
    [[mpviewController moviePlayer] play];
}

- (void)playbackFinishedCallback:(NSNotification *)notification {
    MPMoviePlayerViewController *mpviewController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:mpviewController];
    [mpviewController.view removeFromSuperview];
    [mpviewController 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-30T17:58:31+00:00Added an answer on May 30, 2026 at 5:58 pm

    Have you tried making the movie player controller na ivar

      #import <UIKit/UIKit.h>
      #import <Foundation/Foundation.h>
      #import <MediaPlayer/MediaPlayer.h>
    
      @interface MoviePlayerViewController : UIViewController {
    
      }
    
      @property (nonatomic, retain) MPMoviePlayerViewController *mpviewController;
    
      -(IBAction)playMovie:(id)sender;
      @end
    

    Then you can do something like so in the implementation file

      @synthesize mpviewController;
    
      - (IBAction)playMovie:(id)sender {
          NSString *movpath = [[NSBundle mainBundle] pathForResource:@"think" ofType:@"mp4"];
          MPMoviePlayerViewController *mpController = [[MPMoviePlayerViewController alloc]
                                                           initWithContentURL:[NSURL fileURLWithPath:movpath]];
    
          self.mpviewController = mpController; 
          [mpController release];                                              
    
          [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinishedCallback:)
                                                       name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    
          [self.view addSubview:self.mpviewController.view];
          MPMoviePlayerController *mp = [self.mpviewController moviePlayer];
          [mp prepareToPlay];
          mp.scalingMode=MPMovieScalingModeAspectFill;
          [[self.mpviewController moviePlayer] play];
      }
    
      - (void)playbackFinishedCallback:(NSNotification *)notification {
    
          [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:mpviewController];
          [mpviewController.view removeFromSuperview];
      }
    
      - (void)viewDidUnload {
        self.mpviewController = nil;
      }
    
      - (void)dealloc{
        self.mpviewController = nil;
    
        [super dealloc];
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I am storing variables inside of a class that will be used for
Well i have var message , which has any type of character... I replace
Well friends, I have got this query which works but is very long for
Well I'm designing a Custom WPF control - fore the sake of learning -
Well I run a small video website and on the actual video page there
Well, sad to say, but I have 2 questions, which I wish I could've
well, I just made such a hello world non-Flex app in FlashDevelop and packaged
Well the subject is the question basically. Are there any version control systems out
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed.
Well behaved windows programs need to allow users to save their work when they

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.