开发者

How do I construct a local movie URL properly?

开发者 https://www.devze.com 2023-02-17 20:46 出处:网络
In my iPhone app, the user can click a 开发者_StackOverflow社区table cell, and a movie will start playing. The movie is a local file in my project under \"/Resources/myMovie.m4v\".I can\'t figure out

In my iPhone app, the user can click a 开发者_StackOverflow社区table cell, and a movie will start playing. The movie is a local file in my project under "/Resources/myMovie.m4v". I can't figure out how to properly link to it though.

I found this code, but it doesn't seem to work:

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]];

Thanks for the help!


is the file definitely in the main bundle?

try using this to get the URL.

NSURL *url = [[NSBundle mainBundle] URLForResource:@"myMovie" withExtension:@"m4v"];
   moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
0

精彩评论

暂无评论...
验证码 换一张
取 消