Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

MediaPlayer

I'm trying to make a music player app for iOS and am having some difficulty with MediaPlayer.framework.

Here is some code from my prototype:

- (IBAction)showMediaPicker:(id)sender{

MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny];

mediaPicker.delegate = self;

mediaPicker.allowsPickingMultipleItems = YES;

mediaPicker.prompt = @"Select songs to play";

[self presentViewController:mediaPicker animated:YES completion:nil];

}


- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection

{

if (mediaItemCollection) {

[musicPlayer setQueueWithItemCollection: mediaItemCollection];

[musicPlayer play];

}

[self dismissViewControllerAnimated:YES completion:nil];

}

- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker

{

[self dismissViewControllerAnimated:YES completion:nil];

}

/*

musicPlayer is defined as:

In the .h file:

MPMusicPlayerController *musicPlayer;

@property (nonatomic, retain) MPMusicPlayerController *musicPlayer;

*/

This piece of code brings up a view to pick some songs to play. The problem is that if I pick song a and b, listen to a and decide to add song c and d, only c and d play. This means that the songs are not added to the queue, the queue is deleated and songs are added on top of that. This is also a problem because you can't(at least in the code I use)go back to the previous song or go to the next song unless it is in the queue.

How can I add to the queue without the data being deleated.

Also if you know any good documentation or tutorial on MediaPlayer.framework please share it.

I should also point out that i am in the process of learning iOS development so if it is a general problem could you plaese derect to me some documentation or to a tutorial.

Thanks in advance!

OS X Mountain Lion (10.8.2)

Posted on Mar 22, 2013 8:02 AM

Reply
3 replies

Mar 22, 2013 8:30 AM in response to etresoft

Sorry but as I stated I am new to iOS programming and am self taught. I am learning iOS development using these projects I come up with. I understand what you are saying but I do not know how to implement it in code so could you please explain to me how to do this.

Thanks a lot for tha help! I believe you've helped me before as we'll.

MediaPlayer

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.