美文网首页
流媒体/视频播放(拉流的四种加载方式)

流媒体/视频播放(拉流的四种加载方式)

作者: 请叫我大帅666 | 来源:发表于2018-01-27 08:59 被阅读0次

    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 的方法复制多个, 改变下布局即可
    

    相关文章

      网友评论

          本文标题:流媒体/视频播放(拉流的四种加载方式)

          本文链接:https://www.haomeiwen.com/subject/gezbaxtx.html