I’m trying to replicate the clear queue functionality of the iPod application, however I can’t create an empty MPMediaItemCollection with which to call setQueueWithItemCollection:
e.g.
[self.musicPlayer setQueueWithItemCollection:[MPMediaItemCollection collectionWithItems:[NSArray array]]];
where musicPlayer is a MPMusicPlayerController.
throws an exception:
*** Terminating app due to uncaught exception 'MPMediaItemCollectionInitException', reason: 'items array must not be empty'
Is there a way to clear a MPMusicPLayerController queue that avoids this problem?
Any help is greatly appreciated,
CV
I don’t know if you’ve managed to overcome your problem, but here’s a workaround that seems to be working for me.
This basically sets the play queue up with a query that you’re sure will never turn up any songs. Ideally a query that’s really quick to perform. And then it nullifies the nowPlayingItem and then for good measure tells the player to stop.
Hope that helps.