objective-c 多媒体 视频播放 ( 9.0之后)

//atom

//  ViewController.murl

//  9.0之后视频播放spa

//.net

//  Created by DC017 on 15/12/29.3d

//  Copyright © 2015 DC017. All rights reserved.orm

//视频


#import "ViewController.h"资源

#import <AVKit/AVKit.h>get

#import <AVFoundation/AVFoundation.h>it

@interface ViewController ()

- (IBAction)bofang:(id)sender;

//试图控制器

@property(nonatomic,strong)AVPlayerViewController * playerVC;

@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    //

    NSString * strurl=[[NSBundle mainBundle] pathForResource:@"1" ofType:@"mov"];

    //建立URL

    NSURL *url=[NSURL fileURLWithPath:strurl];

    //实例化播放试图控制器

    AVPlayer * player=[AVPlayer playerWithURL:url];

    AVPlayerLayer *playerLayer=[AVPlayerLayer playerLayerWithPlayer:player];

    playerLayer.frame=CGRectMake(0, 0, 200, 100);

    [self.view.layer addSublayer:playerLayer];

    [player play];

    


}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

}


- (IBAction)bofang:(id)sender {

    //取出本地资源的相对路径

    NSString * strurl=[[NSBundle mainBundle] pathForResource:@"1" ofType:@"mov"];

    //建立URL

    NSURL *url=[NSURL fileURLWithPath:strurl];

    //实例化播放试图控制器

    AVPlayer * player=[AVPlayer playerWithURL:url];

    _playerVC=[[AVPlayerViewController alloc]init];

    _playerVC.player=player;

    //模态跳转

    [self presentViewController:_playerVC animated:YES completion:nil];

}

@end

相关文章
相关标签/搜索