i wanna play music with MPMusicPlayerController.
MPMediaItem * mediaItem = [];
MPMediaItemCollection *songs;
NSArray * array = [NSArray arrayWithObjects:mediaItem, nil];
songs = [MPMediaItemCollection collectionWithItems:array];
[[MPMusicPlayerController iPodMusicPlayer] setQueueWithItemCollection:songs];
i don't know how to give mediaItem, and i have a mp3 file. Help me. thank you!
No, the MPMusicPlayerController will only play music from the Media Library (That's why its located in the MP/MediaPlayer framework) You'll need to use the
AVAudioPlayer
or theAVPlayer
class. A bit more work implementing that unfortunately.Something along the lines of this should get you started: