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. - 从 URL 创建一个
AVURLAsset. - 为资产创建一个
AVAssetReader实例. - 创建一个或多个
AVAssetReaderTrackOutput实例(资产的每个轨道一个)并使用-[AVAssetReader addOutput:]将它们添加到资产阅读器..李> - 调用
-[AVAssetReader startReading]. - 为每个
AVAssetReaderTrackOutput对象调用-copyNextSampleBuffer,直到您读取所有数据.
- Create an
MPMediaQueryto retrieve one or moreMPMediaItemobjects from the iPod library. - Ask those media items for their URL with
-[MPMediaItem valueForProperty: MPMediaItemPropertyAssetURL]. - Create an
AVURLAssetfrom the URL. - Create an instance of
AVAssetReaderfor 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
-copyNextSampleBufferfor each of yourAVAssetReaderTrackOutputobjects until you have read all the data.
有关详细信息,请参阅所有这些类的文档.
See the documentation to all these classes for details.
这篇关于获取 iPod 曲目的音乐数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取 iPod 曲目的音乐数据
基础教程推荐
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
