2

我喜欢用户从可用的音频列表中选择一个音频文件并将其复制到我自己的应用程序中。在 Apple 示例代码“ AddMusic”中检索到的 userMediaItemCollection 项目中,有属性:MPMediaItemPropertyAssetURL。但我无法做到这一点,因为我收到错误“ MPMediaItemPropertyAssetURL undeclared” - 尽管我导入了MPMediaItem.h.

在苹果文档中它说:

MPMediaItemPropertyAssetURL

指向媒体项目的 URL,可以从中创建 AVAsset 对象(或其他基于 URL 的 AV Foundation 对象),并根据需要使用任何选项。值是一个 NSURL 对象。

该 URL 具有 ipod-library 的自定义方案。例如,一个 URL 可能如下所示:ipod-library://item/item.m4a?id=12345

Usage of the URL outside of the AV Foundation framework is not supported.

适用于 iPhone OS 4.0 及更高版本。

在 MPMediaItem.h 中声明


Does that mean, it is not possible to access the audio files for own use?
Is there a workaround?

非常感谢

4

3 回答 3

1

我了解到没有办法做到这一点。正如我在评论中所写 - 只需使用 MPMediaItemPropertyPersistentID .....

于 2010-08-10T22:14:08.150 回答
1

这是一个旧线程,但您可以复制 MPMediaItem。你需要使用AVAssetExportSession虽然而不是NSFileManager

于 2015-05-01T23:15:58.363 回答
0

您应该能够使用 AVURLAsset,并将该 URL 传递给初始化程序。

于 2011-01-07T16:28:03.027 回答