获取iPod音轨的音乐数据 [英] Getting the musical data of an iPod-track

查看:97
本文介绍了获取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):


  1. 创建一个 MPMediaQuery ,从iPod库中检索一个或多个 MPMediaItem 对象。

  2. 使用 - [MPMediaItem valueForProperty:MPMediaItemPropertyAssetURL] 向这些媒体项目询问其网址。

  3. 创建来自URL的AVURLAsset

  4. 为资产创建 AVAssetReader 的实例。

  5. 创建 AVAssetReaderTrackOutput 的一个或多个实例(每个资产轨道一个)并使用将它们添加到资产阅读器中 - [AVAssetReader addOutput:]

  6. 致电 - [AVAssetReader startReading]

  7. 致电 -copy每个 AVAssetReaderTrackOutput 对象的NextSampleBuffer ,直到您读完所有数据。

  1. Create an MPMediaQuery to retrieve one or more MPMediaItem objects from the iPod library.
  2. Ask those media items for their URL with -[MPMediaItem valueForProperty: MPMediaItemPropertyAssetURL].
  3. Create an AVURLAsset from the URL.
  4. Create an instance of AVAssetReader for the asset.
  5. Create one or more instances of AVAssetReaderTrackOutput (one for each track of the asset) and add them to the asset reader with -[AVAssetReader addOutput:].
  6. Call -[AVAssetReader startReading].
  7. Call -copyNextSampleBuffer for each of your AVAssetReaderTrackOutput objects until you have read all the data.

有关详细信息,请参阅所有这些类的文档。

See the documentation to all these classes for details.

这篇关于获取iPod音轨的音乐数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆