码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-11-21 18:20:10      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

原文地址:http://www.cnblogs.com/sharkHZ/p/4984158.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!