0

iPadのローカルiTunesライブラリのビデオであるMPMediaItemがあります。UIView でこれを再生するにはどうすればよいですか? 次のコードは機能しませ

MPMediaItem *video = [allVideos objectAtIndex:indexPath.row];
NSURL *url = [video valueForProperty:MPMediaItemPropertyAssetURL];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[player prepareToPlay];
[player.view setFrame: videoView.bounds];  
[videoView addSubview: player.view];
[player play];
4

1 に答える 1

0

以下が機能しないのはなぜですか?

何も起こりません...

MPMediaItem *song = [allVideos objectAtIndex:indexPath.row];
    NSLog(@"%@",[song valueForProperty:MPMediaItemPropertyAssetURL]);
    NSURL *url = [song valueForProperty:MPMediaItemPropertyAssetURL];
    AVPlayer *player = [[AVPlayer alloc] init];
    AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:url options:nil];
    AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithAsset:avAsset];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playerItemDidReachEnd:)
                                                 name:AVPlayerItemDidPlayToEndTimeNotification
                                               object:playerItem];
    player = [[AVPlayer alloc]initWithPlayerItem:playerItem];

    //[player seekToTime:kCMTimeZero];
    [player play];
于 2014-04-30T13:25:31.117 に答える