Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么我的MPMediaQuery有.items但没有.collections?_Ios_Swift_Media Player_Mpmediaquery - Fatal编程技术网

Ios 为什么我的MPMediaQuery有.items但没有.collections?

Ios 为什么我的MPMediaQuery有.items但没有.collections?,ios,swift,media-player,mpmediaquery,Ios,Swift,Media Player,Mpmediaquery,我又一次为iOS上的MediaPlayer框架挠头了。我只想做一些非常简单的事情,但它不起作用: let query = MPMediaQuery.playlists() query.addFilterPredicate(MPMediaQuery.localItemsOnly) // I extended MPMediaQuery to make this predicate if let items = query.items { // defined. There are item

我又一次为iOS上的MediaPlayer框架挠头了。我只想做一些非常简单的事情,但它不起作用:

let query = MPMediaQuery.playlists()
query.addFilterPredicate(MPMediaQuery.localItemsOnly)  // I extended MPMediaQuery to make this predicate

if let items = query.items {
   // defined. There are items.  A list of MPMediaItem (songs)
}

if let collections = query.collections {
  // does not enter this scope.  Collections are nil
}
我的音乐库有一个手动创建的播放列表和一个智能播放列表(最近播放)

如果items.count>0,则不应将collections.count也设置为>0

[评论]老实说,如果我知道MediaPlayer框架是一个什么样的黑匣子,以及它不“像广告宣传的那样工作”的频率,我永远不会尝试构建这个应用程序!哈哈,我已经放弃了所有的玩家类,在AVQueuePlayer的基础上建立了自己的玩家类。我的意思是说,来吧,MPMusicLayerController必须与internet通信才能更改随机播放模式。。。。由于这个粗略的框架,我真的损失了几个星期