为啥在 MPMusicPlayerController 中设置队列仅在集合中添加第一首曲目?

Posted

技术标签:

【中文标题】为啥在 MPMusicPlayerController 中设置队列仅在集合中添加第一首曲目?【英文标题】:Why is setting queue in a MPMusicPlayerController only adding first track in collection?为什么在 MPMusicPlayerController 中设置队列仅在集合中添加第一首曲目? 【发布时间】:2010-04-17 00:17:46 【问题描述】:

我有一个 Album 对象,其中包含专辑曲目的 MPMediaItemCollection。

当我使用以下代码行将此集合添加到队列中时,只会添加第一个轨道。

[iPodMusicPlayer setQueueWithItemCollection:album.mediaItems];

奇怪的是,当我添加以下代码行时,一切都按预期工作。

[iPodMusicPlayer setQueueWithItemCollection:[MPMediaItemCollection collectionWithItems:[album.mediaItems items]]];

为什么第二行可以工作,而第一行不行?

【问题讨论】:

【参考方案1】:

MPMediaItemCollection Class Reference 没有提到 mediaItems 属性。我猜你正在访问的属性类似于representativeItem,因为这可以解释为什么你只会得到第一首曲目。

您似乎回答了自己的问题。你应该使用:

[MPMediaItemCollection collectionWithItems:[album items]]

【讨论】:

以上是关于为啥在 MPMusicPlayerController 中设置队列仅在集合中添加第一首曲目?的主要内容,如果未能解决你的问题,请参考以下文章

为啥 CoreGui Roblox 锁定在 DataModel 中,为啥受信任的用户不能使用 CoreScripts?

为啥 + 仅在客户端是 NaN?为啥不在 Node.js 中?

在执行语义分割任务时我应该减去图像均值吗?为啥或者为啥不?

为啥我们不能在 TypeScript 类中定义一个 const 字段,为啥静态只读不起作用?

为啥这个函数序言中没有“sub rsp”指令,为啥函数参数存储在负 rbp 偏移处?

为啥这个函数序言中没有“sub rsp”指令,为啥函数参数存储在负 rbp 偏移量?