0
我正在实现一个基于音频的应用程序。我正在使用AVPlayer播放从iPod库中选择的MPMedia项目列表。在我的应用程序中,我需要测试1个案例,那就是我需要将当前正在播放的(来自AVPlayer)与MPMedia项目列表进行比较。我怎样才能做到这一点?为了便于理解,以下是我需要的,如何比较AVPlayer Cureent物品和MPMedia物品?
for(MPMediaItems)
{
if([MPmedia Item]== [AVPlayer CurrentItem])
{
printf("Do some action");
}
}
你们能帮我解决吗?这对我来说非常紧迫。
由于提前, Sekhar
我用下面的代码试过,但不能成功,MPMediaItem * anItem = [歌曲objectAtIndex:指数]; NSURL * itemURL = [anItem valueForProperty:MPMediaItemPropertyAssetURL]; AVAsset * asset = [[AVURLAsset alloc] initWithURL:itemURL options:nil]; NSString * tracksKey = @“tracks”; [asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:tracksKey] completionHandler:^ {AVPlayerItem * item = [AVPlayerItem playerItemWithURL:itemURL]; AVPlayerItem * nextPlayItem = [AVPlayerItem playerItemWithAsset:asset]; if(nextPlayItem == [appDelegate.avPlayer currentItem]) { } }]; – ChandraSekhar