1. AVPlayer
AVPlayer *avplayer = [AVPlayer playerWithURL:[NSURL URLWithString:@""]];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:avplayer];
layer.frame = self.view.bounds;
[self.view.layer addSublayer:layer];
[avplayer play];
2.MPMoviePlayerController
這個(gè)已經(jīng)被廢棄了
MPMoviePlayerController *mpc = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:@""]]; // init
mpc.view.frame = CGRectMake(0, 260, 375, 260); // frame
[self.view addSubview: mpc.view]; // 添加view
[mpc play]; // 播放
3.MPPlayerViewController
也已經(jīng)被廢棄
MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL URLWithString:@""]];
[self presentMoviePlayerViewControllerAnimated:mpvc];
4.UIWebView
NSMutableString *html = [[NSMutableString alloc]init];
[html appendString:@"<html><body style='margin:0'><iframe src='"];
[html appendString:@"url"];
[html appendString:@"' width='320' height='200' frameborder='0'></iframe></body></html>"];
UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 375, 260)];
[self.view addSubview:webView];
[webView loadHTMLString:html baseURL:nil];
當(dāng)你想同時(shí)加載多個(gè)視頻時(shí), 可以將加載 WebView 的方法復(fù)制多個(gè), 改變下布局即可