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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:54:05+00:00 2026-06-07T05:54:05+00:00

I am trying to get a video playing in an iOS applocation, using MPMoviePlayerController

  • 0

I am trying to get a video playing in an iOS applocation, using MPMoviePlayerController to append a movie-view to an existing view when a user pushes a button.
The view appears as a black box on the right position and everything, but nothing happens.
I am expecting the movie to start playing, but nothing happens and no hints from the application on why.

Can anyone see where this goes wrong?

-(IBAction) playButtonClicked:(id)sender
{
    NSString* path = [[NSBundle mainBundle] pathForResource:@"sample_mpeg4" ofType:@"mp4"];
    NSLog(@"Using videoPath %@", path);
    NSURL* url = [NSURL fileURLWithPath:path];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [self.view addSubview:player.view];
    player.view.frame = CGRectMake(10, 10, 300, 220);
   [player play];

}

The movie exists and logs the correct path, but still no movie playing.

2012-07-06 11:51:13.492 experiments[84702:12203] Using videoPath /Users/marius/Library/Application Support/iPhone Simulator/5.1/Applications/9799C851-8D2B-4CFE-8CFA-A4C4C954787F/experiments.app/sample_mpeg4.mp4

From what I have read and understood this should be working.
Any hints or suggestions on what to try?


I moved the movie to a HTTP-server (fg.mp4) and are tailing the access-logs.
When clicking the play-button the usual black window appears.
Serverside i find two new entries in the log:

168.122.x.x - - [06/Jul/2012:22:42:33 +0200] "GET /fg.mp4 HTTP/1.1" 304 192 "-" "AppleCoreMedia/1.0.0.9B176 (iPhone Simulator; U; CPU OS 5_1 like Mac OS X; en_us)"
168.122.x.x - - [06/Jul/2012:22:42:33 +0200] "GET /fg.mp4 HTTP/1.1" 206 33304 "-" "AppleCoreMedia/1.0.0.9B176 (iPhone Simulator; U; CPU OS 5_1 like Mac OS X; en_us)"

So the phone gets parts of the movie content, and -apparently- prepares to get the rest when needed.
Is there some obvious parameter for the MPMoviePlayerController I’m missing?


UPDATE: Solution and working code

The problem is caused by ARC and the fact that no reference to the MPMoviePlayerController were kept after calling the method setting up the controller.
The solution: Adding a class-variable to the class and use this to keep a reference to the controller for the lifetime of the movie.

So early in the class declaration (outside any message/function-definitions):

MPMoviePlayerController* mpController;

And the abeformentioned playButtonClicked uses this variable to keep track of the controller:

NSString* path = [[NSBundle mainBundle] pathForResource:@"sample_mpeg4" ofType:@"mp4"];
NSURL* url = [NSURL fileURLWithPath:path];
mpController = [[MPMoviePlayerController alloc] initWithContentURL:url];
mpController.view.frame = CGRectMake(10, 10, 300, 220);
[self.view addSubview:mpController.view];
[mpController play];
  • 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-07T05:54:06+00:00Added an answer on June 7, 2026 at 5:54 am

    As with my answer to MPMoviePlayerController playback terminates before video finishes, this looks to be a memory management (instance lifetime) issue. Assuming you are compiling with ARC, the player variable is released when your playButtonClicked: method returns. At that point the MPMoviePlayerController instance takes its bat and ball, and goes home.

    Try assigning the MPMoviePlayerController instance to a strong instance variable or property.

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

Sidebar

Related Questions

I'm trying to play video from youtube using this code but I get this
I am trying to get an event to fire when a movie finishes playing.
I am trying to get the filename or URL of the currently playing video
I am trying to get the last playing second when clicking the stop button
I'm trying to get a simple video to play on an iPhone with iOS
I'm trying to get video thumbnails from Vimeo, but for some reason, I cannot
I'm working with PyQt and trying to get video from a webcam to play
I'm trying to get the video data from this youtube playlist feed and add
So, I'm trying to get a video to play from an HTTP url. To
I am trying to get all of the video elements and their attributes from

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.