从音频流获取元数据
我想从我正在使用 AVQueuePlayer 播放的 AVPlayerItem 中的流 URL 获取文件名以及专辑图像(如果可能),但我不知道如何执行此操作。
另外,如果我的流媒体 URL 没有任何元数据,我可以在将元数据传递给 AVPlayerItem 之前将其放入 NSURL*
中吗?
谢谢。
I would like to get the file name and, if possible, album image from a streaming URL in a AVPlayerItem that I am playing with AVQueuePlayer but I don't know how to go about doing this.
Also if it turns out that my streaming URL doesn't have any metadata can I put metadata in my NSURL*
before passing it to the AVPlayerItem?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我很惊讶没有人回答这个问题。
事实上,没有人回答我的任何其他问题。
让我想知道这里的人到底有多少知识。
无论如何,我会继续回答我自己的问题。
我发现了如何通过执行以下操作来获取元数据:
这给了我一个如下列表:
现在有了该列表,我知道如何从音频流访问元数据。只需简单地浏览
NSArray
并查找具有我想要的commonKey
的AVMetadataItem
(例如,title
>)。然后,当我找到AVMetadataItem
时,只需从中获取value
属性。现在,这很有效,但当您尝试获取数据时可能需要一段时间。您可以通过将
loadValuesAsynchronouslyForKeys:completionHandler:
发送到刚刚找到的AVMetadataItem
来异步加载数据。希望这对任何可能遇到同样问题的人有所帮助。
Well I am surprised no one has answered this question.
In fact no one has answered any of my other questions.
Makes me wonder how much knowledge people in here truly have.
Anyways, I will go ahead and answer my own question.
I found out how to get the metadata by doing the following:
Which gives me a list as follows:
With that list now I know how to access the metadata from my audio stream. Just simply go through the
NSArray
and look for anAVMetadataItem
that has thecommonKey
that I want (for example,title
). Then when I find theAVMetadataItem
just get thevalue
property from it.Now, this works great but it may be possible that when you try to get the data it will take a while. You can load the data asynchronously by sending
loadValuesAsynchronouslyForKeys:completionHandler:
to theAVMetadataItem
you just found.Hope that helps to anyone who may find themselves with the same problem.
当检索特定项目时,我将使用 AVMetadataFormat.h 中声明的元数据公共键常量,即:AVMetadataCommonKeyTitle。
When retrieving a particular item I would use the Metadata common keys constant declared in AVMetadataFormat.h, i.e.: AVMetadataCommonKeyTitle.