iOS 多媒体编程

首先了解一下ios系统的四层结构

1. Core OS   核心操作系统层

2. Core Services  核心服务层

3. Media  媒体层

4. cocoa touch层

 

Media层就是支持多媒体播放的

ios9以后官方推荐使用AVKit  和AVFoundtion框架来实现视频的播放

- (IBAction)click:(id)sender

{

    //创建播放器控制器

    AVPlayerViewController * playerVc = [[AVPlayerViewController alloc] init];

    //需要对其属性player进行设置  才能完成视频的播放等一系列功能

    //其player属性是avfoundtion框架中的类

    NSString * path = [[NSBundle mainBundle] pathForResource:@"model" ofType:@".mp4"];

    playerVc.player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];

    //执行播放

    [playerVc.player play];

    [self presentViewController:playerVc animated:YES completion:^{

        NSLog(@"本地视频播放");

    }];

}

 

posted @ 2016-05-03 23:53  iOS贝吉塔星人  阅读(186)  评论(0)    收藏  举报