AVURLAsset loadValuesAsynchronouslyForKeys,同步版本?
有没有办法以同步方式加载 AVURLAsset? 我的场景是,我需要在后台加载资源,同时显示不同的视图,并在资源准备好播放时更改为显示 AVPlayer 的视图。以前没有。
我尝试加载异步并调用委托方法来告诉“资产已准备好,您可以显示下一个视图”,但是如果我在此之前收到内存警告,则包含后台资产的视图会在完成之前被释放正在加载...所以我从来没有接到代表的电话。这就是为什么我宁愿同步进行。
有什么想法吗?
is there a way to load an AVURLAsset in a synchronous manner?
My scenario is one which I need to load the assets in the background while showing a different view and change to the view showing the AVPlayer when the assets are ready to play. Not before.
I've tried loading async and calling a delegate method to tell "the assets are ready, you can show the next view", but if I get a mem warning before that, the views containing the assets in the background get released before they finish loading...so i never get the delegate call. That's why I rather do it synchronously.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是 100% 确定我理解您的意思,但我相信您应该能够使用
[AVURLAsset commonMetadata]
或[AVURLAssetmetadataForFormat:[[AVURLAsset availableMetadataFormats] lastObject]]
,然后在加载此信息后显示您的视图。这些方法返回一个 AVMetadataItem 数组,您应该能够轻松地使用 for 循环遍历该数组。很抱歉,如果这不是您要找的。I'm not 100% sure I understand what you're getting at, but I believe you should be able to just use
[AVURLAsset commonMetadata]
or[AVURLAsset metadataForFormat:[[AVURLAsset availableMetadataFormats] lastObject]]
and then show your view once this information has been loaded. Theses methods return an array ofAVMetadataItem
s, which you should rather easily be able to traverse with a for loop. Sorry if this wasn't what you were looking for.