获取iPod音轨的音乐数据 [英] Getting the musical data of an iPod-track
本文介绍了获取iPod音轨的音乐数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取iPod音轨的内容(原始/样本数据)?我见过像铃声设计师和iMovie这样的应用程序可以做到这一点,但我不知道他们使用哪种API或他们做了什么。我可以想象iMovie使用私有api,但铃声设计师是第三方应用程序,因此必须可以使用公共api函数。
How can I get the content (raw/sample data) of an iPod-track? I've seen apps like "Ringtone Designer" and iMovie which can do it, but I have no idea which api they use or what they do. I could imagine that iMovie uses private apis, but "Ringtone Designer" is a third-party app, so it must be possible with the public api-functions.
推荐答案
我自己没有这样做,但根据文件,这些是步骤(大致):
I haven't done this myself but according to the documentation these are the steps (roughly):
- 创建一个
MPMediaQuery
,从iPod库中检索一个或多个MPMediaItem
对象。 - 使用
- [MPMediaItem valueForProperty:MPMediaItemPropertyAssetURL]
向这些媒体项目询问其网址。 - 创建
来自URL的AVURLAsset
。 - 为资产创建
AVAssetReader
的实例。 - 创建
AVAssetReaderTrackOutput
的一个或多个实例(每个资产轨道一个)并使用将它们添加到资产阅读器中 - [AVAssetReader addOutput:]
。 - 致电
- [AVAssetReader startReading]
。 - 致电
-copy每个
,直到您读完所有数据。AVAssetReaderTrackOutput
对象的NextSampleBuffer
- Create an
MPMediaQuery
to retrieve one or moreMPMediaItem
objects from the iPod library. - Ask those media items for their URL with
-[MPMediaItem valueForProperty: MPMediaItemPropertyAssetURL]
. - Create an
AVURLAsset
from the URL. - Create an instance of
AVAssetReader
for the asset. - Create one or more instances of
AVAssetReaderTrackOutput
(one for each track of the asset) and add them to the asset reader with-[AVAssetReader addOutput:]
. - Call
-[AVAssetReader startReading]
. - Call
-copyNextSampleBuffer
for each of yourAVAssetReaderTrackOutput
objects until you have read all the data.
有关详细信息,请参阅所有这些类的文档。
See the documentation to all these classes for details.
这篇关于获取iPod音轨的音乐数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文