在iOS + youtube url + objective C中播放视频

时间:2017-03-27 06:39:16

标签: ios objective-c avplayer avplayerviewcontroller avkit

要使用AVPlayerViewController播放视频,下面的代码效果很好:

-(void)openVideo{
    NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
    AVPlayer *player = [AVPlayer playerWithURL:videoURL];
    AVPlayerViewController *playerViewController = [AVPlayerViewController new];
    playerViewController.player = player;
    [self.view addSubview: playerViewController.view];
    playerViewController.view.frame = self.view.frame;
    [player play];
    [self presentViewController:playerViewController animated:YES completion:nil];
}

现在我得到这样的网址:

<div class="first-video"><iframe width="560" height="315" src="https://www.youtube.com/embed/8aMHGC6A5zc" frameborder="0" allowfullscreen></iframe></div>

如何在AVPlayer中播放这种(youtube)网址?

0 个答案:

没有答案