[英]Playing video on IOS
我已經從下載了源文件
http://mobile.tutsplus.com/tutorials/iphone/mediaplayer-framework_mpmovieplayercontroller_ios4/
並且該應用程序運行完美,但是當我嘗試通過更改以下代碼來換出自己的視頻時:
pathForResource:@"big-buck-bunny-clip" ofType:@"m4v"
至
pathForResource:@"example" ofType:@"mp4"
當我嘗試播放視頻時,應用程序崩潰,並且在輸出中收到一條消息,提示:
“ 2012-09-13 20:32:59.106 BigBuckBunny [1081:11f03] *由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因: - [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)
我的新視頻文件與原始big-buck-bunny-clip.m4v文件一起位於文件夾內,並將其放入項目中。 我在做什么錯,我該如何解決?
通過轉到Xcode中的文件並選中“目標成員身份”下BigBuckBunny旁邊的框,我設法播放了自己的視頻
檢查文件出口和傳遞的文件路徑是否為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.