我正在实现一个基于音频的应用程序。在这种情况下,我使用AVPlayer来播放从iPod库中选择的MPMedia项目列表。在我的应用程序中,我需要测试1个案例,那就是我需要比较当前播放(从AVPlayer)与MPMedia项目列表。我该怎么做呢?
为了便于理解,我需要以下内容:
for(MPMediaItems)
{
if([MPmedia Item]== [AVPlayer CurrentItem])
{
printf("Do some action");
}
}
MPMediaItem *song;
NSURL *songURL = [song valueForProperty: MPMediaItemPropertyAssetURL];
AVURLAsset *asset1 = (AVURLAsset *)[_avPlayer.currentItem asset]; //currentItem is AVAsset type so incompitable pointer types ... notification will occur, however it does contain URL (see with NSLog)
AVURLAsset *asset2 = [AVURLAsset URLAssetWithURL: songURL options: nil];
if ([asset1.URL isEqual: asset2.URL]) {
printf("Do some action");
}