#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];
}