开发者社区> 问答> 正文

关于MPMoviePlayerController播放视频

代码片段:

theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:@"/Resources/disc.mp4"]];
    theMoviPlayer.controlStyle = MPMovieControlStyleFullscreen;
    theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
    UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
    [theMoviPlayer.view setFrame:backgroundWindow.frame];
    [backgroundWindow addSubview:theMoviPlayer.view];
    [theMoviPlayer play];

不知道应该怎么添加视频到项目中?应该把视频文件添加到哪个文件夹中?

展开
收起
爵霸 2016-03-19 09:06:59 1755 0
1 条回答
写回答
取消 提交回答
  • 试试:

    NSString *path=[[NSBundle mainBundle] pathForResource:@"disc" ofType:@"mp4"];
    NSURL *fileURL=[NSURL fileURLWithPath:path];
    theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    ......
    2019-07-17 19:07:10
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
全景视频的播放及优化 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载