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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:18:54+00:00 2026-05-27T00:18:54+00:00

Im new to xCode programming, ive got this code from an ebook tutorial playing

  • 0

Im new to xCode programming, ive got this code from an ebook tutorial playing mp4 xCode.

function triggered from a button

(IBAction)playMovie:(id)sender {
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"videoSample" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath]; 
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
[self.view addSubview:moviePlayerController.view]; 
moviePlayerController.fullscreen=YES;
[moviePlayerController play];
moviePlayerController.scalingMode = MPMovieScalingModeFill;
}

called from play movie function

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

Ive got no error and warning after i build it. it just output a blank screen after i click the button that triggers the playMovie function. Im confuse ive google it and still got no idea on how to solve the proble.

Im using xCode 4.2 iOS SDK 5.0

  • 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-27T00:18:55+00:00Added an answer on May 27, 2026 at 12:18 am

    try this….replace “example” with the name of your file and “m4v” with the type of file e.g. “mp4” (not .mp4 and dont put the .mp4 bit in the name of the file)

    -(IBAction)playVideo:(id)sender;
    {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"example" ofType:@"m4v"];
    
    
    MPMoviePlayerViewController* tmpMoviePlayViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
    
    if (tmpMoviePlayViewController) {
    
        tmpMoviePlayViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    
        [self presentModalViewController:tmpMoviePlayViewController animated:YES];
    
        tmpMoviePlayViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
    
        [[NSNotificationCenter defaultCenter] addObserver:self
    
                                            selector:@selector(myMovieViewFinishedCallback:)
    
                                            name:MPMoviePlayerPlaybackDidFinishNotification
    
                                            object:tmpMoviePlayViewController];
    
        [tmpMoviePlayViewController.moviePlayer play];
    }
    

    }

    -(void)myMovieFinishedCallback:(NSNotification*)theNotification
    {
        MPMoviePlayerController *moviePlayer=[theNotification object];
    
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:moviePlayer];
    
    [moviePlayer.view removeFromSuperview];
    

    }

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

Sidebar

Related Questions

I'm starting a new xCode project. I'm porting in some code from my last
Hey there, I'm a designer thats really new to programming with xcode or Objective-C
Whenever I make a new file in xcode, it puts something like this at
I recently updated to the new version of XCode and the session start code
When building a new iPhone app in Xcode, I'm getting this error: codesign error:
Hi there I am new to C programming and have been using Xcode to
I am new to iPhone programming and have a MacBook running Leopard with XCode
I'm new to xcode and cocoa. According to the Framework Programming Guide , there
I'm new to Xcode and objective C programming and I'm having some troubles building
I am new to Xcode and objective C programming.Please help me to resolve 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.