ZFFullScreenViewController.m 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // ZFFullScreenViewController.m
  3. // ZFPlayer_Example
  4. //
  5. // Created by 紫枫 on 2018/8/29.
  6. // Copyright © 2018年 紫枫. All rights reserved.
  7. //
  8. #import "ZFFullScreenViewController.h"
  9. #import <ZFPlayer/ZFAVPlayerManager.h>
  10. #import <ZFPlayer/ZFIJKPlayerManager.h>
  11. #import <ZFPlayer/ZFPlayerControlView.h>
  12. #import <ZFPlayer/ZFPlayerConst.h>
  13. #import "ZFSmallPlayViewController.h"
  14. static NSString *kVideoCover = @"https://upload-images.jianshu.io/upload_images/635942-14593722fe3f0695.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
  15. @interface ZFFullScreenViewController ()
  16. @property (nonatomic, strong) ZFPlayerController *player;
  17. @property (nonatomic, strong) ZFPlayerControlView *controlView;
  18. @end
  19. @implementation ZFFullScreenViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.view.backgroundColor = [UIColor blackColor];
  23. @zf_weakify(self)
  24. self.controlView.backBtnClickCallback = ^{
  25. @zf_strongify(self)
  26. [self.player rotateToOrientation:UIInterfaceOrientationPortrait animated:NO completion:nil];
  27. [self.player stop];
  28. [self dismissViewControllerAnimated:NO completion:nil];
  29. };
  30. ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
  31. /// 播放器相关
  32. self.player = [[ZFPlayerController alloc] initWithPlayerManager:playerManager containerView:self.view];
  33. self.player.controlView = self.controlView;
  34. self.player.orientationObserver.supportInterfaceOrientation = ZFInterfaceOrientationMaskLandscape;
  35. /// 设置转屏方向
  36. [self.player rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:NO completion:nil];
  37. playerManager.assetURL = [NSURL URLWithString:@"https://www.apple.com/105/media/us/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-tpl-cc-us-20170912_1280x720h.mp4"];
  38. }
  39. - (void)viewWillDisappear:(BOOL)animated {
  40. [super viewWillDisappear:animated];
  41. }
  42. - (UIStatusBarStyle)preferredStatusBarStyle {
  43. return UIStatusBarStyleLightContent;
  44. }
  45. - (BOOL)prefersStatusBarHidden {
  46. return self.player.isStatusBarHidden;
  47. }
  48. - (BOOL)shouldAutorotate {
  49. return NO;
  50. }
  51. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  52. return UIInterfaceOrientationMaskLandscape;
  53. }
  54. - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
  55. return UIInterfaceOrientationLandscapeRight;
  56. }
  57. - (ZFPlayerControlView *)controlView {
  58. if (!_controlView) {
  59. _controlView = [ZFPlayerControlView new];
  60. _controlView.fastViewAnimated = YES;
  61. _controlView.effectViewShow = NO;
  62. _controlView.prepareShowLoading = YES;
  63. _controlView.showCustomStatusBar = YES;
  64. }
  65. return _controlView;
  66. }
  67. @end