进击的UI--------------UIAVPlayer(视频)

孤者浪人 提交于 2020-02-11 04:46:09
#import "RootViewController.h"
#import <AVFoundation/AVFoundation.h>// 引入
@interface RootViewController ()
@property (nonatomic,strong)AVPlayer *player;
@property (nonatomic,strong)AVPlayerItem *item;
@end
@implementation RootViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // 1 url
    NSURL *url = [NSURL URLWithString:@"http://v.jxvdy.com/sendfile/w5bgP3A8JgiQQo5l0hvoNGE2H16WbN09X-ONHPq3P3C1BISgf7C-qVs6_c8oaw3zKScO78I--b0BGFBRxlpw13sf2e54QA"];
//   NSURL *url1 = [NSURL alloc]initFileURLWithPath:<#(NSString *)#>
    // 2 item
    self.item = [[AVPlayerItem alloc]initWithURL:url];
    self.player = [AVPlayer playerWithPlayerItem:_item];
    // 3 player
    AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:_player];
    // 4 layer
    layer.frame = CGRectMake(0, 100, self.view.frame.size.width, 300);
    // 5 加上
    [self.view.layer addSublayer:layer];
    // 6 play
    [_player play];
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!