我需要按字母顺序排列 ipod 队列。
使用以下代码,歌曲不按字母顺序排列
MPMediaQuery *everything = [[MPMediaQuery alloc] init];
everything = [MPMediaQuery songsQuery];
[musicPlayer setQueueWithQuery:everything];
[self.musicPlayer play]
使用以下代码,歌曲按字母顺序排列,但加载时间超过 60 秒
MPMediaQuery *everything = [[MPMediaQuery alloc] init];
everything = [MPMediaQuery songsQuery];
[everything setGroupingType: MPMediaGroupingTitle];
NSArray *collections = [everything collections];
MPMediaItemCollection *firstCollection = [collections
objectAtIndex:0];
NSMutableArray *combinedMediaItems = [[firstCollection items]
mutableCopy];
for(int i = 1; i < [collections count]; i++) {
NSArray *newMediaItems = [[collections objectAtIndex:i] items];
[combinedMediaItems addObjectsFromArray: newMediaItems];
}
[self.musicPlayer setQueueWithItemCollection: [MPMediaItemCollection
collectionWithItems: (NSArray *) combinedMediaItems]];
[self.musicPlayer play];
你能帮助我吗?谢谢。