ZFOrientationObserver.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // ZFOrentationObserver.h
  3. // ZFPlayer
  4. //
  5. // Copyright (c) 2016年 任子丰 ( http://github.com/renzifeng )
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. #import <UIKit/UIKit.h>
  25. NS_ASSUME_NONNULL_BEGIN
  26. /// Full screen mode
  27. typedef NS_ENUM(NSUInteger, ZFFullScreenMode) {
  28. ZFFullScreenModeAutomatic, // Determine full screen mode automatically
  29. ZFFullScreenModeLandscape, // Landscape full screen mode
  30. ZFFullScreenModePortrait // Portrait full screen Model
  31. };
  32. /// Full screen mode on the view
  33. typedef NS_ENUM(NSUInteger, ZFRotateType) {
  34. ZFRotateTypeNormal, // Normal
  35. ZFRotateTypeCell, // Cell
  36. ZFRotateTypeCellOther // Cell mode add to other view
  37. };
  38. /**
  39. Rotation of support direction
  40. */
  41. typedef NS_OPTIONS(NSUInteger, ZFInterfaceOrientationMask) {
  42. ZFInterfaceOrientationMaskPortrait = (1 << 0),
  43. ZFInterfaceOrientationMaskLandscapeLeft = (1 << 1),
  44. ZFInterfaceOrientationMaskLandscapeRight = (1 << 2),
  45. ZFInterfaceOrientationMaskPortraitUpsideDown = (1 << 3),
  46. ZFInterfaceOrientationMaskLandscape = (ZFInterfaceOrientationMaskLandscapeLeft | ZFInterfaceOrientationMaskLandscapeRight),
  47. ZFInterfaceOrientationMaskAll = (ZFInterfaceOrientationMaskPortrait | ZFInterfaceOrientationMaskLandscapeLeft | ZFInterfaceOrientationMaskLandscapeRight | ZFInterfaceOrientationMaskPortraitUpsideDown),
  48. ZFInterfaceOrientationMaskAllButUpsideDown = (ZFInterfaceOrientationMaskPortrait | ZFInterfaceOrientationMaskLandscapeLeft | ZFInterfaceOrientationMaskLandscapeRight),
  49. };
  50. @interface ZFOrientationObserver : NSObject
  51. /// update the rotateView and containerView.
  52. - (void)updateRotateView:(UIView *)rotateView
  53. containerView:(UIView *)containerView;
  54. /// list play
  55. - (void)cellModelRotateView:(UIView *)rotateView
  56. rotateViewAtCell:(UIView *)cell
  57. playerViewTag:(NSInteger)playerViewTag;
  58. /// cell other view rotation
  59. - (void)cellOtherModelRotateView:(UIView *)rotateView
  60. containerView:(UIView *)containerView;
  61. /// Container view of a full screen state player.
  62. @property (nonatomic, strong) UIView *fullScreenContainerView;
  63. /// Container view of a small screen state player.
  64. @property (nonatomic, weak) UIView *containerView;
  65. /// If the full screen.
  66. @property (nonatomic, readonly, getter=isFullScreen) BOOL fullScreen;
  67. /// Use device orientation, default NO.
  68. @property (nonatomic, assign) BOOL forceDeviceOrientation;
  69. /// Lock screen orientation
  70. @property (nonatomic, getter=isLockedScreen) BOOL lockedScreen;
  71. /// The block invoked When player will rotate.
  72. @property (nonatomic, copy, nullable) void(^orientationWillChange)(ZFOrientationObserver *observer, BOOL isFullScreen);
  73. /// The block invoked when player rotated.
  74. @property (nonatomic, copy, nullable) void(^orientationDidChanged)(ZFOrientationObserver *observer, BOOL isFullScreen);
  75. /// Full screen mode, the default landscape into full screen
  76. @property (nonatomic) ZFFullScreenMode fullScreenMode;
  77. /// rotate duration, default is 0.30
  78. @property (nonatomic) float duration;
  79. /// The statusbar hidden.
  80. @property (nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden;
  81. /// The current orientation of the player.
  82. /// Default is UIInterfaceOrientationPortrait.
  83. @property (nonatomic, readonly) UIInterfaceOrientation currentOrientation;
  84. /// Whether allow the video orientation rotate.
  85. /// default is YES.
  86. @property (nonatomic) BOOL allowOrentitaionRotation;
  87. /// The support Interface Orientation,default is ZFInterfaceOrientationMaskAllButUpsideDown
  88. @property (nonatomic, assign) ZFInterfaceOrientationMask supportInterfaceOrientation;
  89. /// Add the device orientation observer.
  90. - (void)addDeviceOrientationObserver;
  91. /// Remove the device orientation observer.
  92. - (void)removeDeviceOrientationObserver;
  93. /// Enter the fullScreen while the ZFFullScreenMode is ZFFullScreenModeLandscape.
  94. - (void)enterLandscapeFullScreen:(UIInterfaceOrientation)orientation animated:(BOOL)animated;
  95. /// Enter the fullScreen while the ZFFullScreenMode is ZFFullScreenModePortrait.
  96. - (void)enterPortraitFullScreen:(BOOL)fullScreen animated:(BOOL)animated;
  97. /// Exit the fullScreen.
  98. - (void)exitFullScreenWithAnimated:(BOOL)animated;
  99. @end
  100. NS_ASSUME_NONNULL_END