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
这个已经被废弃了
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
也已经被废弃
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];
当你想同时加载多个视频时, 可以将加载 WebView 的方法复制多个, 改变下布局即可
网友评论