gpt4 book ai didi

ios - 如何在 AVPlayer 中提取 MPMediaItemCollection 到 NSData?

转载 作者:行者123 更新时间:2023-11-29 10:55:47 27 4
gpt4 key购买 nike

我想在我的应用程序中使用 avplayer 播放设备歌曲。在 NSLog 中,我得到数组值 ===> “18023427656013653237”, "15946441828903552798", "10791915036547881152", “17986655796364263078”//现在我想知道这些值是什么......

这个我试过了......

-(IBAction)SelectSongs:(id)sender
{

MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAny];
picker.delegate = self;
picker.allowsPickingMultipleItems =YES;
picker.prompt = @"Select songs from the list";

[self presentViewController:picker animated:YES completion:^(void) {}];
}

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


if (mediaItemCollection)
{
NSMutableArray *medialibraryArray;
medialibraryArray=[[NSMutableArray alloc]init];
[medialibraryArray addObject:mediaItemCollection.items];// Modified
NSLog(@"%@=========>",medialibraryArray);


}
[self dismissViewControllerAnimated:YES completion:^(void) {}];}

-(void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
{
[self dismissViewControllerAnimated:YES completion:^(void) {}];
}


// Thanks in Advance

最佳答案

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


if (mediaItemCollection)
{
NSArray *items = [mediaItemCollection items];
for( int n=0; n < items.count; n++ ) {
MPMediaItem *mediaItem = [items objectAtIndex:n];
NSLog(@"%@=========>",[mediaItem valueForProperty:MPMediaItemPropertyTitle]);
}

MPMusicPlayerController *musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
[musicPlayer setQueueWithItemCollection: mediaItemCollection];
NSLog(@"==>%@",musicPlayer);


}
[self dismissViewControllerAnimated:YES completion:^(void) {}];
}

您将使用它获取您音乐库中的所有歌曲,因此打印输出可能需要一段时间!阅读 MPMediaItem 类引用和媒体查询,了解如何获取整个音乐库的子集。

关于ios - 如何在 AVPlayer 中提取 MPMediaItemCollection 到 NSData?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18467503/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com