0

我正在实现一个基于音频的应用程序。我正在使用 AVPlayer 播放从 iPod 库中选择的 MPMedia 项目列表。在我的应用程序中,我需要测试 1 个案例,即我需要将当前播放的(来自 AVPlayer)与 MPMedia 项目列表进行比较。我怎样才能做到这一点?

为了便于理解,我需要以下内容:

for(MPMediaItems)
{
   if([MPmedia Item]== [AVPlayer CurrentItem])
    {

        printf("Do some action");
    }
}
4

1 回答 1

3
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");
}
于 2011-10-06T09:14:52.080 回答