iTunes 匹配 + AV 播放器 + MPMediaQuery 不工作
我正在开发一个使用 AVPlayer、MPMediaItem 和 MPMediaQuery 的应用程序。只要 Itunes 匹配就可以使用。我们从 MPMediaQuery 开始,然后执行一些过滤,留下一些 MPMediaItems,然后我们一直使用 AVPlayer,因为: 1.- 我们还在歌曲播放期间播放噪音 2.- 我们需要订阅 iPod 的播放/停止事件。
所有这些功能目前都可以使用,除非 iPod 库启用了 iTunes 匹配。即使AVPlayer状态正在播放,也没有声音。很明显,它没有触发从 iCloud 下载歌曲。
目前我所掌握的关于 itunes match 的所有信息都是这篇文章: MPMediaItem 和 iTunes Match
表明您可以使用 MPMusicPlayerController 播放调用来触发下载。由于上述原因,我们无法利用此类来控制我们自己的播放器。
对于如何解决这个问题我有两个想法: A. 找到一种方法来检查歌曲是否已下载并可在库中使用 AVPlayer 播放。如果歌曲不可用,请让用户知道我们不支持不可用的歌曲。 B.找到一种方法在歌曲成为下一个要播放的项目之前触发歌曲的下载。
我仍然找不到如何实现这些解决方案,也没有找到任何相关文档,因此我提交了我的应用程序并附有一条警告消息,以防止用户在使用 itunes match 时使用此应用程序。
I'm developing an app which makes usage of AVPlayer, MPMediaItem and MPMediaQuery. It works as long as Itunes match. We start with a MPMediaQuery, then we perform some filtering leaving some MPMediaItems, then we have been using AVPlayer because:
1.- we also play noises during the song play
2.- we need to suscribe to play/stops events from ipod.
All this features are currently working, except if the ipod library has itunes match enabled. Even when AVPlayer status is playing, no sound comes. Is obvious that it is not triggering the song download from iCloud.
All the information I have about itunes match by the moment is this post:
MPMediaItem and iTunes Match
which states you can trigger the download by using a MPMusicPlayerController play call. For the reasons given above, we cannot make use of this class to control our own player.
I have two ideas on how to solve this problem:
A. Find a way to check if a song is already downloaded and available in the library to play using AVPlayer. If the song is not available let the user know that we don't support songs not available.
B. Find a way to trigger the download of the song just before it becomes the next item to play.
I still cannot find how to implement any of these solutions and I haven't found any related documentation, so I submitted my app with a warning message to prevent users to use this app if they are using itunes match.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 iOS 6 及更高版本上,您可以使用
[[item valueForProperty:MPMediaItemPropertyIsCloudItem] boolValue]
检查项目是否已下载。On iOS 6 and up you can use
[[item valueForProperty:MPMediaItemPropertyIsCloudItem] boolValue]
to check if an item is already downloaded.这并不完美,但在大多数情况下都有效。从 iTunes Match 下载的歌曲将不受 DRM 保护。因此,您可以检查资产 DRM 标志,如果不可导出,则需要下载。有声读物/播客可能会出现误报,但基本上是安全的。
您可以尝试在静音的 MPMusicPlayerController 上执行此操作,但无法跟踪歌曲的下载时间,有时需要很长时间。
This isn't perfect but it works in most cases. Songs downloaded from iTunes Match will be DRM free. So you can check the assets DRM flags, if it is not exportable then it needs to be downloaded. It is possible to get a false positive with audio books/pod casts but you are mostly safe.
You can try doing this will a muted MPMusicPlayerController, but there is no way to track when the song is downloaded and sometimes it takes a very long time.