获取 iPod 曲目的音乐数据

Getting the musical data of an iPod-track(获取 iPod 曲目的音乐数据)

本文介绍了获取 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] 询问这些媒体项目的 URL.
  3. 从 URL 创建一个 AVURLAsset.
  4. 为资产创建一个 AVAssetReader 实例.
  5. 创建一个或多个 AVAssetReaderTrackOutput 实例(资产的每个轨道一个)并使用 -[AVAssetReader addOutput:] 将它们添加到资产阅读器..李>
  6. 调用-[AVAssetReader startReading].
  7. 为每个 AVAssetReaderTrackOutput 对象调用 -copyNextSampleBuffer,直到您读取所有数据.
  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 曲目的音乐数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:获取 iPod 曲目的音乐数据

基础教程推荐