Just to first say that I’m a total coding noob and so I’m probably trying to do something above my knowledge level. I went online and sought code for adding a video to an x-code program. I tried various different online tutorials and none of them worked.
I tried at first to program it into Xcode 4.2 but to no avail. I then downloaded the latest version 4.5
The build succeeds in the iphone6 simulator but then it fails to actually run.
The error message I’m getting is a SIGABERT:- * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[NSURL initFileURLWithPath:]: nil string parameter’
My header file is:-
#import UIkit/UIkit.h (with the smaller than larger than symbols)
#import MediaPlayer/MediaPlayer.h (with the smaller than larger than symbols)
@interface ViewController :UIViewController {
}
-(IBAction)playvideo;
@end
My implementation file is:-
#import "ViewController".h
#import <UIKit/UIKit.h>
@implementation ViewController
-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource:@"jamcookvid1" ofType:@"mv4"]];
MPMoviePlayerViewController *playercontroller =
[[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[self navigationController]presentMoviePlayerViewControllerAnimated:
playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
// [playercontroller release];
playercontroller = nil;
}
@end
If any of you guys could help me – it would be much appreciated. JB
It’s likely that your file doesn’t exist in the app bundle…or not with that exact spelling. Try logging the result of
[[NSBundle mainBundle] pathForResource:@"jamcookvid1" ofType:@"mv4"]. You will probably find it’snil, which would explain the message.