简体   繁体   English

iPhone - MPMusicPlayerController - 从队列中选择音频并播放

[英]iPhone - MPMusicPlayerController - Selecting audio from the queue and play it

I'm using MPMusicPlayerController in my application.我在我的应用程序中使用 MPMusicPlayerController。 I'm setting a queue using method "setQueueWithItemCollection".我正在使用方法“setQueueWithItemCollection”设置队列。 I'm able to play the songs, move to prev/next songs etc. But how can I make MPMusicPlayerController play some 5th song from the queue?我可以播放歌曲,移至上一首/下一首歌曲等。但是如何让 MPMusicPlayerController 播放队列中的第 5 首歌曲?

when you set the queue, save the queue somewhere else that you can access.设置队列时,将队列保存在您可以访问的其他位置。 if you want to play the fifth song, use MPMusicPlayerController.nowPlayingItem= [[queue items] objectAtIndex:4] and it will play the fifth song.如果要播放第五首歌曲,请使用 MPMusicPlayerController.nowPlayingItem= [[queue items] objectAtIndex:4] 它将播放第五首歌曲。 you don't have to skip 5 times.您不必跳过 5 次。

you have to maintain another list of queue in your application.您必须在应用程序中维护另一个队列列表。 Then everytime, when you to jump to another song, get players current item, compare it from your array iterating through it and at the same time use skip to prev or next song from music player.然后每次,当您跳到另一首歌曲时,获取播放器当前项目,从您的数组迭代比较它,同时使用跳转到音乐播放器中的上一首或下一首歌曲。 no other solution found.没有找到其他解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM