开发者

MPMediaPickerController - select a whole album

开发者 https://www.devze.com 2023-03-26 13:26 出处:网络
I have a MPMediaPickerController in an iPhone application that prompts a user to select a song they wish to play.

I have a MPMediaPickerController in an iPhone application that prompts a user to select a song they wish to play.

What I want to accomplish is similar to the Music/iPod app that is bundled with the operating system on the device. I want the user to select a song from an album but then add all the songs from the album to the "playlist" to play.

So for example: A user selects the 3rd song from an album of 10 开发者_如何转开发songs. I want to populate the items to play with all the songs from that album with the "playlist" index set to 3, just like the Music/iPod App.

Can someone provide me with code for Xcode that will enable me to perform this, what seems, tedious task?

Thanks.


I had the same problem, resorted to using a third party library: https://github.com/jaminguy/JGMediaPicker


Check out the AddMusic sample app from Apple

http://developer.apple.com/library/ios/#samplecode/AddMusic/Introduction/Intro.html

Using this as your starting point you'll then need to look into Apple's MPMediaQuery documentation, specifically the "albumsQuery" constructor. This allows you to create a mediaItemCollection (or playlist) which contains only the mediaItems which conform to your criteria.

0

精彩评论

暂无评论...
验证码 换一张
取 消