I just want to show the list of default ringtones to allow the user select one to set as ringtone for a new notification. Is that possible?
#import <MediaPlayer/MediaPlayer.h>
- (IBAction) AddMusicOrShowMusic: (id) sender
{
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = NO;
picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item picker");
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];
[self presentViewController:picker animated:YES completion:NULL];
[picker release];
}
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
[self dismissViewControllerAnimated:YES completion:nil];
item = [[mediaItemCollection items] objectAtIndex:0];
NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
NSLog(@"url : %@",url);
}
- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
{
[self dismissViewControllerAnimated:YES completion:nil];
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated: YES];
}