You don't need to copy any specific files from the example, just some of the functions.
To pick the music you use MPMediaPickerController , look at AddMusicOrShowMusic in MainViewController.m to see how to instantiate that and what delegate methods you need to implement.
The important class you need to use to play the music is MPMusicPlayerController. In MainViewController.m you'll see the methods you need to implement and how to use it, see - (IBAction) playOrPauseMusic: (id)sender { for example.
Essentially you'll take the media items returned by MPMediaPickerController and call setQueueWithItemCollection on the MPMediaPickerController to queue up the music. After that it's really just a case of calling play/pause/etc and updating your interface.
The code you need is all in there, you just need to pull out the right bits.
发布评论
评论(1)
您不需要从示例中复制任何特定文件,只需复制一些函数即可。
要选择您使用的音乐 MPMediaPickerController ,查看 MainViewController.m 中的 AddMusicOrShowMusic 以了解如何实例化它以及需要实现哪些委托方法。
您需要用来播放音乐的重要类是 MPMusicPlayerController。在 MainViewController.m 中,您将看到需要实现的方法以及如何使用它,例如,请参阅 - (IBAction) playOrPauseMusic: (id)sender { 。
本质上,您将获取 MPMediaPickerController 返回的媒体项目,并在 MPMediaPickerController 上调用 setQueueWithItemCollection 来对音乐进行排队。之后,这实际上只是调用播放/暂停/等并更新界面的情况。
您需要的代码都在那里,您只需提取正确的部分即可。
You don't need to copy any specific files from the example, just some of the functions.
To pick the music you use MPMediaPickerController , look at AddMusicOrShowMusic in MainViewController.m to see how to instantiate that and what delegate methods you need to implement.
The important class you need to use to play the music is MPMusicPlayerController. In MainViewController.m you'll see the methods you need to implement and how to use it, see - (IBAction) playOrPauseMusic: (id)sender { for example.
Essentially you'll take the media items returned by MPMediaPickerController and call setQueueWithItemCollection on the MPMediaPickerController to queue up the music. After that it's really just a case of calling play/pause/etc and updating your interface.
The code you need is all in there, you just need to pull out the right bits.