如何从资产库中播放视频文件 [英] How to play video file from asset library
本文介绍了如何从资产库中播放视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从资源库播放视频文件?我有文件的网址,如
How to play the video file from assets library? I have the URL of file like
"assets-library://asset/asset.MOV?id=1000000023&ext=MOV"
但是我无法使用以下代码在媒体播放器中播放此文件:
But I am unable to play this file in media player using the following code:
NSString *urlAddress = @"assets-library://asset/asset.mov?id=1000000023&ext=mov";
NSURL *theURL = [NSURL URLWithString:urlAddress];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
推荐答案
我也遇到了问题,并得到了解决方案。我使用了以下代码,它对我有用。 urlAddress
是 ALAssetsLibrary
的视频网址。
I was also getting problem, and got the solution. I used the following code and it worked for me. The urlAddress
is the url for the video by 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];
}
这篇关于如何从资产库中播放视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文