MPMediaItem 和 iTunes 匹配
我有一个应用程序,它使用 iPod Library API 来访问 iOS 中的歌曲数据库。随着 iTunes Match 的发布,任何不在设备上的歌曲都将无法加载。有什么办法可以请求下载这首歌吗?也许使用新的 iCloud API?
编辑: 需要明确的是,我并不是在问如何使用 iPhone 通过 iTunes Match 下载歌曲。 iOS SDK 允许通过 MPMediaQuery/MPMediaItems 访问 iPod 库。在启用了 iTunes Match 的 iOS 设备上,iTunes Match 库中但不在设备本地的歌曲将通过 MPMediaQuery 返回,但 MPMediaItems 的“可导出”标志设置为 false。当我在音乐应用程序中访问这些歌曲时,它们会自动下载。我想通过 MPMediaItem 触发相同的自动下载。
我在 iTunes Match 中看到过一些项目被称为 iCloud 的一部分,并且 iOS 5 SDK 中有一个新的 iCloud 部分。然而,据我了解,我只能获取我的应用程序上传的数据。我希望有一种方法可以通过 MPMediaItem 或通过 iCloud 使用 URL 来触发 iTunes Match 下载。
I have an app that uses the iPod Library API to access the song database in iOS. With the release of iTunes Match, any song which is not on the device will fail to load. Is there a way I an request that the song be downloaded? Perhaps using the new iCloud API?
Edit:
To be clear I am not asking how to download songs with iTunes Match using the iPhone. The iOS SDK allows access to the iPod Library via the MPMediaQuery/MPMediaItems. On a iOS device with iTunes Match enabled songs which are in your iTunes Match library but not local on the device are returned via a MPMediaQuery however the MPMediaItems have their 'exportable' flag set to false. When I access these songs in the Music app they are automatically downloaded. I would like to trigger the same automatic download via the MPMediaItem.
I have seen items in iTunes Match refereed to as part of iCloud and there is a new iCloud section of the iOS 5 SDK. However as I understand it I can only get data my app as uploaded. I was hoping there was a way via the MPMediaItem or using the URL via iCloud to trigger an iTunes Match download.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我发现了一些东西,但它不是很好。如果您选择要通过 iPod 播放器播放的歌曲,则会触发下载。您可以使用 MPMusicPlayerController 访问 iPod 播放器。
没有关于这是否真正开始下载或下载进度的反馈,但该项目将开始下载,如果您的连接良好,它将第一次播放(否则您可以垃圾邮件播放,它会开始下载)。
I have found something, but it isn't great. If you select the song to be played through the iPod player then that will trigger a download. You can access the iPod player with an MPMusicPlayerController.
No feedback on if this really started a download or not, or progress on the download but the item will start downloading and if your connection is good it will play the first time (otherwise you can spam play and it will get around to starting).
我刚刚收到 Apple 关于此问题的回复(我使用了我的技术支持事件之一)。
据苹果公司称,iOS SDK 目前不提供任何用于从 iCloud 启动下载的 API。我被指示通过Apple 的错误报告工具提交此功能的增强请求。我会鼓励其他人也这样做。
考虑到 iCloud 是 iOS 5 的定义功能之一,苹果确实应该为从 iCloud 下载音频资源提供编程支持。
I just heard back from Apple regarding this issue (I used one of my Technical Support Incidents).
According to Apple, the iOS SDK does not currently provide any APIs for initiating a download from iCloud. I was instructed to file an enhancement request for this feature via Apple's bug reporter tool. I would encourage others to do the same.
Apple really should provide programmatic support for downloading audio assets from iCloud considering that iCloud is one of the defining features of iOS 5.
MPMediaItem | iCloud 或 DRM 保护
上面的链接显示了如何使用 iOS 6 中引入的属性来查看 MPMediaItem 是否在云中。
MPMediaItemPropertyIsCloudItem
这是使用宏来确保只有 iOS 6 使用 iOS 6 添加的代码。下面是宏。
据我所知,您仍然无法启动下载。
MPMediaItem | iCloud or DRM Protected
The link above shows how you can use a property introduced in iOS 6 to see if an MPMediaItem is in the cloud.
MPMediaItemPropertyIsCloudItem
That is using a macro to ensure only iOS 6 uses that code which was added with iOS 6. Below is that macro.
Still you cannot initiate a download as far as I can tell.
这里有一些需要注意的事情。我的应用程序执行普通的
[MPMediaQuery albumsQuery]
来收集所有专辑及其歌曲。即使整个音乐库由 iTunes Match 内容组成(其中大部分仍位于云端),这种方法也能正常工作。但有一个问题:如果当时正在播放一首歌,并且该歌曲位于云端,那么现在正在下载该歌曲,那么该歌曲和专辑中的下一首歌曲就会丢失来自
[MPMediaQuery albumsQuery]
的结果。这大概是因为这些歌曲正在“传输中”:它们都已部分下载。 (我假设总是下载两首歌曲,这样当第一首歌曲完成时,就可以无缝地继续到下一首歌曲。)此外,播放并下载歌曲会触发
MPMediaLibraryDidChangeNotification
,即使“目录”图书馆的“事实上并没有改变。我没有看到任何解决这个问题的方法,因为没有其他方法可以查询该库。 Apple 需要修复系统和 API 以考虑 iTunes Match 的存在。不幸的是,我没有感觉到他们正在为 iOS 5.1 开发这个......
Here's something to watch out for. My app does an ordinary
[MPMediaQuery albumsQuery]
to gather all albums and their songs. This works fine even if the whole music library consists of iTunes Match stuff most of which is still in the cloud. But there's one problem:If a song is being played at that moment, and if that song was in the cloud, so that now it is being downloaded, that song and the next song in the album are missing from the result of
[MPMediaQuery albumsQuery]
. This is presumably because those songs are "in transit": they are both partially downloaded. (I presume two songs are always downloaded so that when the first finishes it is possible to segue seamlessly into the next.)Moreover, playing and therefore downloading a song triggers an
MPMediaLibraryDidChangeNotification
even though the "table of contents" of the library has not in fact changed.I don't see any way around this, since there's no other way to query the library. Apple needs to fix the system and the APIs to take account of iTunes Match's existence. Unfortunately I am not getting a sense that they are working on this for iOS 5.1...