如何从资产库中播放视频文件

编程入门 行业动态 更新时间:2024-10-25 16:25:14
本文介绍了如何从资产库中播放视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何从资源库播放视频文件?我有文件的网址,如

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

更多推荐

如何从资产库中播放视频文件

本文发布于:2023-07-11 09:24:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093572.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视频文件   库中   资产

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!