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

发布于 2024-08-29 08:58:10 字数 376 浏览 4 评论 0原文

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

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

[iPodMusicPlayer setQueueWithItemCollection:album.mediaItems];

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

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

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

I have an Album object containing a MPMediaItemCollection of the album's tracks.

When I add this collecton to the queue with the following line of code, only the first track gets added.

[iPodMusicPlayer setQueueWithItemCollection:album.mediaItems];

Oddly enough when I add with the following line of code, everything works as expected.

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

Why would the second line work but not the first?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坏尐絯 2024-09-05 08:58:10

MPMediaItemCollection 类参考 不提及 mediaItems 属性。我猜您正在访问的属性类似于 representativeItem,因为这可以解释为什么您只能获得第一首曲目。

看来你回答了你自己的问题。你应该使用:

[MPMediaItemCollection collectionWithItems:[专辑项]]

The MPMediaItemCollection Class Reference makes no mention of a mediaItems property. I'd guess the property you're accessing is similar to representativeItem, as that would explain why you'd only get the first track.

It looks like you answered your own question. You should use:

[MPMediaItemCollection collectionWithItems:[album items]]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文