rot*_*ice 1 iphone objective-c mpmovieplayercontroller ios4 ios
在我的iPhone应用程序中,用户可以单击表格单元格,电影将开始播放.该电影是我项目中"/Resources/myMovie.m4v"下的本地文件.我无法弄清楚如何正确链接到它.
我发现了这段代码,但它似乎不起作用:
NSString *rootPath = [[NSBundle mainBundle] resourcePath];
NSString *filePath = [rootPath stringByAppendingPathComponent:@"myMovie.m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath:filePath isDirectory:NO]];
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
小智 5
绝对是主包中的文件?
尝试使用它来获取URL.
NSURL *url = [[NSBundle mainBundle] URLForResource:@"myMovie" withExtension:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1626 次 |
| 最近记录: |