MPMediaItem和iTunes Match [英] MPMediaItem and iTunes Match

查看:109
本文介绍了MPMediaItem和iTunes Match的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用iPod Library API访问iOS中歌曲数据库的应用。随着iTunes Match的发布,任何不在设备上的歌曲都将无法加载。有没有办法要求下载这首歌?也许使用新的iCloud API?

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?

编辑:
要明确我不会问如何使用iPhone下载iTunes Match歌曲。 iOS SDK允许通过MPMediaQuery / MPMediaItems访问iPod库。在具有iTunes Match功能的iOS设备上,通过MPMediaQuery返回iTunes Match库中但不在设备本地的歌曲,但MPMediaItems的'exportable'标志设置为false。当我在音乐应用程序中访问这些歌曲时,它们会自动下载。我想通过MPMediaItem触发相同的自动下载。

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.

我已经看到iTunes中的项目作为iCloud的一部分被评审,并且有一个新的iCloud部分iOS 5 SDK。但据我了解,我只能上传我的应用程序数据。我希望通过MPMediaItem或通过iCloud使用URL来触发iTunes Match下载。

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.

推荐答案

我找到了一些东西,但它并不好。如果您选择要通过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.

MPMusicPlayerController *mDRMAudioPlayer;
mDRMAudioPlayer = [MPMusicPlayerController iPodMusicPlayer];

MPMediaQuery *assetQuery = [[MPMediaQuery alloc] init];
NSNumber *persistentID = [mediaItem valueForProperty: MPMediaItemPropertyPersistentID];
MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue: persistentID 
                                                                       forProperty: MPMediaItemPropertyPersistentID];
[assetQuery addFilterPredicate: predicate];

[mDRMAudioPlayer setQueueWithQuery: assetQuery];
[mDRMAudioPlayer play];

没有关于这是否真的开始下载的反馈,或下载的进展但项目将开始下载,如果您的连接良好,它将第一次播放(否则您可以进行垃圾邮件播放,它将开始播放)。

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).

这篇关于MPMediaItem和iTunes Match的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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