如何从资源库播放视频文件?我有像
这样的文件的URL"assets-library://asset/asset.MOV?id=1000000023&ext=MOV"
但是我无法使用以下代码在媒体播放器中播放此文件:
NSString *urlAddress = @"assets-library://asset/asset.mov?id=1000000023&ext=mov";
NSURL *theURL = [NSURL URLWithString:urlAddress];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
答案 0 :(得分:5)
我也遇到了问题,并得到了解决方案。我使用了以下代码,它对我有用。 urlAddress
是ALAssetsLibrary
的视频网址。
-(void)playVideo:(NSString *)urlAddress{
NSString *newUrl = [[NSString alloc] initWithFormat:@"%@",urlAddress];
NSURL *theURL = [NSURL URLWithString:newUrl];
//player = [[MPMoviePlayerController alloc] init];
[player setContentURL:theURL];
[player prepareToPlay];
[player play];
}