简体   繁体   English

在IOS上播放视频

[英]Playing video on IOS

I have downloaded the source files from 我已经从下载了源文件

http://mobile.tutsplus.com/tutorials/iphone/mediaplayer-framework_mpmovieplayercontroller_ios4/ http://mobile.tutsplus.com/tutorials/iphone/mediaplayer-framework_mpmovieplayercontroller_ios4/

and the app works perfectly, but when I try to swap out my own video by changing the following code: 并且该应用程序运行完美,但是当我尝试通过更改以下代码来换出自己的视频时:

pathForResource:@"big-buck-bunny-clip" ofType:@"m4v"

to

pathForResource:@"example" ofType:@"mp4"

the app crashes when I try to play the video and I receive a message in the output saying: 当我尝试播放视频时,应用程序崩溃,并且在输出中收到一条消息,提示:

"2012-09-13 20:32:59.106 BigBuckBunny[1081:11f03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' “ 2012-09-13 20:32:59.106 BigBuckBunny [1081:11f03] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因: -[NSURL initFileURLWithPath:]: nil string parameter' * * First throw call stack: (0x1722022 0x10f6cd6 0x16caa48 0x16ca9b9 0x4e53b 0x4e4c5 0x2da4 0x1723e99 0x36d14e 0x36d0e6 0x413ade 0x413fa7 0x413266 0x3923c0 0x3925e6 0x378dc4 0x36c634 0x1e1aef5 0x16f6195 0x165aff2 0x16598da 0x1658d84 0x1658c9b 0x1e197d8 0x1e1988a 0x36a626 0x297d 0x28f5) terminate called throwing an exception(lldb) " - [NSURL initFileURLWithPath:]:零字符串参数” * *第一掷调用堆栈:(0x1722022 0x10f6cd6 0x16caa48 0x16ca9b9 0x4e53b 0x4e4c5 0x2da4 0x1723e99 0x36d14e 0x36d0e6 0x413ade 0x413fa7 0x413266 0x3923c0 0x3925e6 0x378dc4 0x36c634 0x1e1aef5 0x16f6195 0x165aff2 0x16598da 0x1658d84 0x1658c9b 0x1e197d8 0x1e1988a 0x36a626 0x297d 0x28f5)终止叫引发异常(lldb)

I have my new video file inside the folder with the original big-buck-bunny-clip.m4v file, and I put it in the project. 我的新视频文件与原始big-buck-bunny-clip.m4v文件一起位于文件夹内,并将其放入项目中。 What am I doing wrong and how do I fix this? 我在做什么错,我该如何解决?

通过转到Xcode中的文件并选中“目标成员身份”下BigBuckBunny旁边的框,我设法播放了自己的视频

Check file exits and filepath you r passing is nil: 检查文件出口和传递的文件路径是否为nil:

 NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"example" ofType:@"mp4"];  
 if([[NSFileManager defaultManager] fileExitsAtPath:filepath])
 {
   NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];   
   MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];  
   [self.view addSubview:moviePlayerController.view];  
   moviePlayerController.fullscreen = YES;  
   [moviePlayerController play];    
 }
 else
 {
    NSLog(@"File not exists");
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM