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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:55:52+00:00 2026-06-11T23:55:52+00:00

Here is the code that I wrote to play a video in my Xcode

  • 0

Here is the code that I wrote to play a video in my Xcode project. When I run the project it crashes on me. I get this reason: Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[NSURL initFileURLWithPath:]: nil string parameter’

I’ve found a tutorial that works when I run it on the simulator.
I added my video to the project and updated the code accordingly. My video is in a m4v format just like the other video in the tutorial. When I run the app with my video it still crashes and gives me the same error. I took my video from quick time and exported it over to iTunes. What am I doing wrong?

.h file

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

@interface BigBuckBunnyViewController : UIViewController {

}

-(IBAction)playMovie:(id)sender;

@end

.m file

#import "BigBuckBunnyViewController.h"

@implementation BigBuckBunnyViewController

-(IBAction)playMovie:(id)sender
{
UIButton *playButton = (UIButton *) sender; 

NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"ladder rack 1 4"  
ofType:@"m4v"];
NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] 
initWithContentURL:fileURL];

[[NSNotificationCenter defaultCenter] addObserver:self

selector:@selector(moviePlaybackComplete:)

name:MPMoviePlayerPlaybackDidFinishNotification

object:moviePlayerController];

[moviePlayerController.view setFrame:CGRectMake(playButton.frame.origin.x, 

playButton.frame.origin.y, 

playButton.frame.size.width, 

playButton.frame.size.height)];

[self.view addSubview:moviePlayerController.view];
//moviePlayerController.fullscreen = YES;

//moviePlayerController.scalingMode = MPMovieScalingModeFill;

[moviePlayerController play];
}

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

name:MPMoviePlayerPlaybackDidFinishNotification

object:moviePlayerController];

[moviePlayerController.view removeFromSuperview];
[moviePlayerController release];
}

- (void)dealloc {
[super dealloc];
}

@end

Ok so I was able to create an html page and link the html page to my .m file in the view did load section. I created an UIWebview and added it to my xib view. I placed my video on a server. This is probably a better solution, less load time.

  • 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-11T23:55:53+00:00Added an answer on June 11, 2026 at 11:55 pm

    You are geting nil because the NSString *filepath = [[NSBundle mainBundle] pathForResource:@"ladder rack 1 4" ofType:@"m4v"]; contains spaces.
    So you need to change it like:

    NSURL   *fileURL    =   [NSURL fileURLWithPath:filepath] absoluteString];
    

    Refer this link

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

Sidebar

Related Questions

I cannot get this to work, here is code that I found in another
here is a small peice off code that i wrote. But I am not
So, here's the problem. I wrote a code that opens a div based on
Here is my Code that I'm trying to run on Mac OS X: import
Here is the code that doesn't work: Enemy.strength = srand((unsigned)time(NULL)) % 10; Enemy.strength is
Here is my code that adds a line to the grid by pressing the
Here is the code that cause me problem since few hours: TabItem newTab =
Here's my code that is not working: print To: ; my $to=<>; chomp $to;
Here is my code that fails: bool Table::win(const Card &card) { for (int i
Here is the code that I have for my cell of my UITableView: forKeys:[NSArray

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.