1.添加MediaPlayer.framework 框架
2.实例化视频播放器
- (void)playVideo{
_playerVC = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@”1440848648989” ofType:@”mp4”]]];
[_playerVC.view setFrame:CGRectMake(50, 50, 924, 650)];
// 设定播放模式
/*
MPMovieControlStyleNone, // No controls
MPMovieControlStyleEmbedded, // Controls for an embedded view
MPMovieControlStyleFullscreen, // Controls for fullscreen playback
*/
_playerVC.controlStyle = MPMovieControlStyleEmbedded ;
// 控制模式 ( 触摸 )
/*
MPMovieScalingModeNone, // No scaling
MPMovieScalingModeAspectFit, // Uniform scale until one dimension fits
MPMovieScalingModeAspectFill, // Uniform scale until the movie fills the visible bounds. One dimension may have clipped contents
MPMovieScalingModeFill // Non-uniform scale. Both render dimensions will exactly match the visible bounds
*/
_playerVC.scalingMode = MPMovieScalingModeAspectFill ;
[self.view addSubview:_playerVC.view];
[_playerVC play];
}
本实例 只能播放本地视频不能播放网络视频
播放网络视频后续更新