iOS简单的视频播放

2015-03-03 0 500
iOS简单的视频播放

导入 MediaPlayer.framework

- (void)viewDidLoad
{
    [super viewDidLoad];
     
    NSString* path = [[NSBundle mainBundle] pathForResource:@"test1" ofType:@"mp4"];
    NSURL* url = [NSURL fileURLWithPath:path];
    _playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
     
    UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100, 100, 100, 40);
    button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(play) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}
 
- (void)play{
    [self presentMoviePlayerViewControllerAnimated:_playerController];
    //播放
    [_playerController.moviePlayer play];
}

遇见资源网 objective-c iOS简单的视频播放 http://www.ox520.com/16117.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务