1>视频播放:
// 播放视频(流媒体)
NSString *videoUrl = [NSString stringWithFormat:@"http://192.168.1.200:8080/MJServer/%@", video.url];
HMMoviePlayerViewController *playerVc = [[HMMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoUrl]];
[self presentMoviePlayerViewControllerAnimated:playerVc];
// 只能全屏播放
// MPMoviePlayerController; // 可以随意控制播放器的尺寸
2>在进入后台后MPMoviePlayerViewController会自动销毁,所以自定义HMMoviePlayerViewController,移除通知:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
}
并且在HMMoviePlayerViewController实现横屏播放:
/**
* 控制当前控制器支持哪些方向
* 返回值是UIInterfaceOrientationMask*
*/
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}