因此,我已经在NSUserDefaults中存储了很少的NSUserDefaults。我已经在UICollectionView上检索了它。
这是我的代码:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
self.performSegueWithIdentifier("toList", sender: self)
User.mdci = decodedPlaylistData[indexPath.row] as? MPMediaItemCollection
getSongListInfo((decodedPlaylistData[indexPath.row] as? MPMediaItemCollection)!)
MPMusicPlayerController().setQueueWithItemCollection((decodedPlaylistData[indexPath.row] as? MPMediaItemCollection)!)
MPMusicPlayerController().nowPlayingItem = (decodedPlaylistData[indexPath.row] as? MPMediaItemCollection)!.items[0] as! MPMediaItem
MPMusicPlayerController().play()
}下面是decodedPlaylisData数组:
(
"<MPMediaItemCollection: 0x165c5d00>",
"<MPMediaItemCollection: 0x165c6c30>",
"<MPMediaItemCollection: 0x165c7390>",
"<MPMediaItemCollection: 0x165c7c60>"
)上面的代码应该根据indexPath.row播放每个媒体集合。
getSongListInfo是一个获取图像、标题、相册、艺术家等所有信息的函数,我将其发送到一个结构中。它的工作原理如下所示:

我可以从MPMediaItemCollection获得歌曲信息,但是我不能播放MPMediaItemCollection的歌曲
我怎样才能解决这个问题?
注意:它实际上是在播放MPMediaItemCollection,但是当我单击另一个UICollectionViewCell时,它不会播放
发布于 2015-06-05 18:24:12
此代码创建三个独立的音乐播放器控制器。创建一个并将其存储在一个变量中,然后将消息发送给它。
MPMusicPlayerController().setQueueWithItemCollection((decodedPlaylistData[indexPath.row] as? MPMediaItemCollection)!)
MPMusicPlayerController().nowPlayingItem = (decodedPlaylistData[indexPath.row] as? MPMediaItemCollection)!.items[0] as! MPMediaItem
MPMusicPlayerController().play()https://stackoverflow.com/questions/30663089
复制相似问题