How to play video file from asset library

2019-06-21 09:58发布

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

1条回答
该账号已被封号
2楼-- · 2019-06-21 10:15

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

}
查看更多
登录 后发表回答