可以使用MPMediaPickerController直接打开播放列表选项卡

时间:2011-03-29 09:45:48

标签: iphone-sdk-3.0 mpmediapickercontroller

我正在实现一个基本应用程序,它允许从应用程序中的音乐中选择播放列表。我做到了。但我的问题是它直接显示音乐标签。但是根据我的要求,我需要在用户进入该视图时显示播放列表选项卡。以下是我的代码,

   MPMediaPickerController *picker =
    [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];

    picker.delegate                     = self;
    picker.allowsPickingMultipleItems   = YES;
    picker.prompt                       = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some songs to play");

    // The media item picker uses the default UI style, so it needs a default-style
    //      status bar to match it visually
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];

    [self presentModalViewController: picker animated: YES];
    [picker release];

2 个答案:

答案 0 :(得分:2)

-(IBAction)btnSelectSong:(id)sender
{

       MPMediaPickerController *picker =
        [[MPMediaPickerController alloc]
         initWithMediaTypes: MPMediaTypeAnyAudio];

        [picker setDelegate: self];
        [picker setAllowsPickingMultipleItems: YES];
        picker.prompt =
        NSLocalizedString (@"Add songs to play",
                           "Prompt in media item picker");

        [self presentModalViewController: picker animated: YES];

}

答案 1 :(得分:0)

根据Apple的文档,

无法在MPMediaPickerController的播放列表部分打开

我已在这里回答: 您需要使用媒体查询(按歌曲,按艺术家等)实现自己的选择器。

您需要使用媒体查询(按歌曲,按艺术家等)实现自己的选择器。

我建议在Apple的“iPod Library Access Programming Guide”中阅读:“Using the iPod Library”

更具体: MPMediaPlaylist Class Ref