首先要说我是一个完全编码的菜鸟,所以我可能正在尝试做一些超出我知识水平的事情。我上网并寻找将视频添加到 x-code 程序的代码。我尝试了各种不同的在线教程,但都没有奏效。我起初尝试将它编程到 Xcode 4.2 中,但无济于事。然后我下载了最新版本 4.5
构建在 iphone6 模拟器中成功,但随后无法实际运行。
我收到的错误消息是 SIGABERT:- * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[NSURL initFileURLWithPath:]: nil string parameter”
我的头文件是:-
#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
我的实现文件是:-
#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
如果你们中的任何人可以帮助我 - 将不胜感激。JB