DDZFPlayerKit_Private update

This commit is contained in:
DDIsFriend
2023-08-31 16:17:11 +08:00
parent a53ff1b89e
commit efb4113402
155 changed files with 8382 additions and 9399 deletions

View File

@@ -12,7 +12,7 @@
<key>OrderSchedulingNotificationService.xcscheme_^#shared#^_</key> <key>OrderSchedulingNotificationService.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>41</integer> <integer>40</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>

View File

@@ -11,7 +11,7 @@ import DDAutoUIKit_Private
import RxSwift import RxSwift
import RxCocoa import RxCocoa
import RxRelay import RxRelay
import ZFPlayer import DDZFPlayerKit_Private
extension RescuePhotoController : UICollectionViewDelegate,UICollectionViewDataSource { extension RescuePhotoController : UICollectionViewDelegate,UICollectionViewDataSource {
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

View File

@@ -255,10 +255,11 @@ PODS:
- DDWebImageKit_Private/SDWebImage/Core (0.1.3) - DDWebImageKit_Private/SDWebImage/Core (0.1.3)
- DDWebImageKit_Private/SDWebImage/MapKit (0.1.3): - DDWebImageKit_Private/SDWebImage/MapKit (0.1.3):
- DDWebImageKit_Private/SDWebImage/Core - DDWebImageKit_Private/SDWebImage/Core
- DDZFPlayerKit_Private/ControlView (0.1.0): - DDZFPlayerKit_Private/ControlView (0.1.1):
- ZFPlayer/Core - DDZFPlayerKit_Private/Core
- DDZFPlayerKit_Private/ijkplayer (0.1.0): - DDZFPlayerKit_Private/Core (0.1.1)
- ZFPlayer/Core - DDZFPlayerKit_Private/ijkplayer (0.1.1):
- DDZFPlayerKit_Private/Core
- ESTabBarController-swift (2.8.0) - ESTabBarController-swift (2.8.0)
- IQKeyboardManagerSwift (6.5.12) - IQKeyboardManagerSwift (6.5.12)
- JCore (4.2.1) - JCore (4.2.1)
@@ -276,7 +277,6 @@ PODS:
- RxSwift (6.5.0) - RxSwift (6.5.0)
- SnapKit (5.6.0) - SnapKit (5.6.0)
- SwiftEntryKit (2.0.0) - SwiftEntryKit (2.0.0)
- ZFPlayer/Core (4.1.4)
- ZLPhotoBrowser (4.4.3.2): - ZLPhotoBrowser (4.4.3.2):
- ZLPhotoBrowser/Core (= 4.4.3.2) - ZLPhotoBrowser/Core (= 4.4.3.2)
- ZLPhotoBrowser/Core (4.4.3.2) - ZLPhotoBrowser/Core (4.4.3.2)
@@ -346,7 +346,6 @@ SPEC REPOS:
- RxSwift - RxSwift
- SnapKit - SnapKit
- SwiftEntryKit - SwiftEntryKit
- ZFPlayer
- ZLPhotoBrowser - ZLPhotoBrowser
SPEC CHECKSUMS: SPEC CHECKSUMS:
@@ -370,7 +369,7 @@ SPEC CHECKSUMS:
DDTimerKit_Private: 3713d029a72710f42a5dd5a32083d6aad8f51eb0 DDTimerKit_Private: 3713d029a72710f42a5dd5a32083d6aad8f51eb0
DDToastKit_Private: b6ae3709d110cadca503a037419f3709d1755256 DDToastKit_Private: b6ae3709d110cadca503a037419f3709d1755256
DDWebImageKit_Private: b905111547e44626773b729bae9030403a9a0c76 DDWebImageKit_Private: b905111547e44626773b729bae9030403a9a0c76
DDZFPlayerKit_Private: 20f001957c24e1e3b6c0b758ae866a2944be2149 DDZFPlayerKit_Private: 5f63a8101e35ffd7b2568f551cbf33b8bedc48ba
ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136 ESTabBarController-swift: 05593a6ad64700b03c0eb60ff625916370aa4136
IQKeyboardManagerSwift: 371b08cb39664fb56030f5345c815a4ffc74bbc0 IQKeyboardManagerSwift: 371b08cb39664fb56030f5345c815a4ffc74bbc0
JCore: d994e32edb50add8a33135473acca799d882c5fa JCore: d994e32edb50add8a33135473acca799d882c5fa
@@ -384,7 +383,6 @@ SPEC CHECKSUMS:
RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8 RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
SwiftEntryKit: 61b5fa36f34a97dd8013e48a7345bc4c4720be9a SwiftEntryKit: 61b5fa36f34a97dd8013e48a7345bc4c4720be9a
ZFPlayer: 5cf39e8d9f0c2394a014b0db4767b5b5a6bffe13
ZLPhotoBrowser: 0563c2bfc7b247b65d023d646012f46cba94101b ZLPhotoBrowser: 0563c2bfc7b247b65d023d646012f46cba94101b
PODFILE CHECKSUM: a50398c9fdc8f5753f43e8d3315d35e180ab0c05 PODFILE CHECKSUM: a50398c9fdc8f5753f43e8d3315d35e180ab0c05

View File

@@ -453,7 +453,7 @@ Scroll to indexPath with position.
}]; }];
// First visible cell indexPath // First visible cell indexPath
indexPath = isLast ? sortedIndexPaths.lastObject : sortedIndexPaths.firstObject; indexPath = sortedIndexPaths.firstObject;
if ((self.contentOffset.y <= 0 || isLast) && (!self.zf_playingIndexPath || [indexPath compare:self.zf_playingIndexPath] == NSOrderedSame)) { if ((self.contentOffset.y <= 0 || isLast) && (!self.zf_playingIndexPath || [indexPath compare:self.zf_playingIndexPath] == NSOrderedSame)) {
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIView *playerView = [cell viewWithTag:self.zf_containerViewTag]; UIView *playerView = [cell viewWithTag:self.zf_containerViewTag];
@@ -558,7 +558,7 @@ Scroll to indexPath with position.
}]; }];
// First visible cell indexPath // First visible cell indexPath
indexPath = isLast ? sortedIndexPaths.lastObject : sortedIndexPaths.firstObject; indexPath = sortedIndexPaths.firstObject;
if ((self.contentOffset.x <= 0 || isLast) && (!self.zf_playingIndexPath || [indexPath compare:self.zf_playingIndexPath] == NSOrderedSame)) { if ((self.contentOffset.x <= 0 || isLast) && (!self.zf_playingIndexPath || [indexPath compare:self.zf_playingIndexPath] == NSOrderedSame)) {
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIView *playerView = [cell viewWithTag:self.zf_containerViewTag]; UIView *playerView = [cell viewWithTag:self.zf_containerViewTag];

View File

@@ -23,27 +23,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <objc/runtime.h> #import <objc/runtime.h>
#import "ZFLandscapeWindow.h"
#import "ZFLandscapeRotationManager.h"
API_AVAILABLE(ios(13.0)) @implementation UIViewController (ZFPlayerFixSafeArea)
/// Hook
- (void)zf_setContentOverlayInsets:(UIEdgeInsets)insets andLeftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin {
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
UIWindow *otherWindow = self.view.window;
if ([keyWindow isKindOfClass:ZFLandscapeWindow.class] && otherWindow != nil) {
ZFLandscapeRotationManager *manager = ((ZFLandscapeWindow *)keyWindow).rotationManager;
UIWindow *superviewWindow = manager.containerView.window;
if (superviewWindow != otherWindow) {
[self zf_setContentOverlayInsets:insets andLeftMargin:leftMargin rightMargin:rightMargin];
}
} else {
[self zf_setContentOverlayInsets:insets andLeftMargin:leftMargin rightMargin:rightMargin];
}
}
@end
@implementation UITabBarController (ZFPlayerRotation) @implementation UITabBarController (ZFPlayerRotation)
@@ -57,33 +36,15 @@ API_AVAILABLE(ios(13.0)) @implementation UIViewController (ZFPlayerFixSafeArea)
for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) { for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) {
SEL originalSelector = selectors[index]; SEL originalSelector = selectors[index];
SEL swizzledSelector = NSSelectorFromString([@"zf_" stringByAppendingString:NSStringFromSelector(originalSelector)]); SEL swizzledSelector = NSSelectorFromString([@"zf_" stringByAppendingString:NSStringFromSelector(originalSelector)]);
[self hookClass:self.class originalSelector:originalSelector swizzledSelector:swizzledSelector]; Method originalMethod = class_getInstanceMethod(self, originalSelector);
} Method swizzledMethod = class_getInstanceMethod(self, swizzledSelector);
if (class_addMethod(self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) {
double systemVersion = [UIDevice currentDevice].systemVersion.doubleValue; class_replaceMethod(self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
if (systemVersion >= 13.0 && systemVersion < 16.0) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
/// _setContentOverlayInsets:andLeftMargin:rightMargin:
NSData *data = [NSData.alloc initWithBase64EncodedString:@"X3NldENvbnRlbnRPdmVybGF5SW5zZXRzOmFuZExlZnRNYXJnaW46cmlnaHRNYXJnaW46" options:kNilOptions];
NSString *method = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
SEL originalSelector = NSSelectorFromString(method);
#pragma clang diagnostic pop
SEL swizzledSelector = @selector(zf_setContentOverlayInsets:andLeftMargin:rightMargin:);
[self hookClass:UIViewController.class originalSelector:originalSelector swizzledSelector:swizzledSelector];
}
});
}
+ (void)hookClass:(Class)cls originalSelector:(SEL)orlSelector swizzledSelector:(SEL)swzdSelector {
Method originalMethod = class_getInstanceMethod(cls, orlSelector);
Method swizzledMethod = class_getInstanceMethod(cls, swzdSelector);
if (class_addMethod(self, orlSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) {
class_replaceMethod(self, swzdSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
} else { } else {
method_exchangeImplementations(originalMethod, swizzledMethod); method_exchangeImplementations(originalMethod, swizzledMethod);
} }
}
});
} }
- (NSInteger)zf_selectedIndex { - (NSInteger)zf_selectedIndex {

View File

@@ -28,16 +28,28 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol ZFLandscapeViewControllerDelegate <NSObject> @protocol ZFLandscapeViewControllerDelegate <NSObject>
@optional
- (BOOL)ls_shouldAutorotate; - (BOOL)ls_shouldAutorotate;
- (void)rotationFullscreenViewController:(ZFLandscapeViewController *)viewController viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator; - (void)ls_willRotateToOrientation:(UIInterfaceOrientation)orientation;
- (void)ls_didRotateFromOrientation:(UIInterfaceOrientation)orientation;
- (CGRect)ls_targetRect;
@end @end
@interface ZFLandscapeViewController : UIViewController @interface ZFLandscapeViewController : UIViewController
@property (nonatomic, weak) UIView *contentView;
@property (nonatomic, weak) UIView *containerView;
@property (nonatomic, assign) CGRect targetRect;
@property (nonatomic, weak, nullable) id<ZFLandscapeViewControllerDelegate> delegate; @property (nonatomic, weak, nullable) id<ZFLandscapeViewControllerDelegate> delegate;
@property (nonatomic, readonly) BOOL isFullscreen;
@property (nonatomic, getter=isRotating) BOOL rotating;
@property (nonatomic, assign) BOOL disableAnimations; @property (nonatomic, assign) BOOL disableAnimations;
@property (nonatomic, assign) BOOL statusBarHidden; @property (nonatomic, assign) BOOL statusBarHidden;
@@ -46,6 +58,8 @@ NS_ASSUME_NONNULL_BEGIN
/// defalut is UIStatusBarAnimationSlide. /// defalut is UIStatusBarAnimationSlide.
@property (nonatomic, assign) UIStatusBarAnimation statusBarAnimation; @property (nonatomic, assign) UIStatusBarAnimation statusBarAnimation;
@property (nonatomic, copy) void(^rotatingCompleted)(void);
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,140 @@
//
// ZFFullScreenViewController.m
// ZFPlayer
//
// Copyright (c) 2020 ( http://github.com/renzifeng )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "ZFLandscapeViewController.h"
@interface ZFLandscapeViewController ()
@property (nonatomic, assign) UIInterfaceOrientation currentOrientation;
@end
@implementation ZFLandscapeViewController
- (instancetype)init {
self = [super init];
if (self) {
_currentOrientation = UIInterfaceOrientationPortrait;
_statusBarStyle = UIStatusBarStyleLightContent;
_statusBarAnimation = UIStatusBarAnimationSlide;
}
return self;
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
self.rotating = YES;
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) {
return;
}
UIInterfaceOrientation newOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
UIInterfaceOrientation oldOrientation = _currentOrientation;
if (UIInterfaceOrientationIsLandscape(newOrientation)) {
if (self.contentView.superview != self.view) {
[self.view addSubview:self.contentView];
}
}
if (oldOrientation == UIInterfaceOrientationPortrait) {
self.contentView.frame = [self.delegate ls_targetRect];
[self.contentView layoutIfNeeded];
}
self.currentOrientation = newOrientation;
[self.delegate ls_willRotateToOrientation:self.currentOrientation];
BOOL isFullscreen = size.width > size.height;
if (self.disableAnimations) {
[CATransaction begin];
[CATransaction setDisableActions:YES];
}
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
if (isFullscreen) {
self.contentView.frame = CGRectMake(0, 0, size.width, size.height);
} else {
self.contentView.frame = [self.delegate ls_targetRect];
}
[self.contentView layoutIfNeeded];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
if (self.disableAnimations) {
[CATransaction commit];
}
[self.delegate ls_didRotateFromOrientation:self.currentOrientation];
if (!isFullscreen) {
self.contentView.frame = self.containerView.bounds;
[self.contentView layoutIfNeeded];
}
self.disableAnimations = NO;
self.rotating = NO;
}];
}
- (BOOL)isFullscreen {
return UIInterfaceOrientationIsLandscape(_currentOrientation);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotate {
return [self.delegate ls_shouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
UIInterfaceOrientation currentOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
if (UIInterfaceOrientationIsLandscape(currentOrientation)) {
return UIInterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskAll;
}
- (BOOL)prefersHomeIndicatorAutoHidden {
UIInterfaceOrientation currentOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
if (UIInterfaceOrientationIsLandscape(currentOrientation)) {
return YES;
}
return NO;
}
- (BOOL)prefersStatusBarHidden {
return self.statusBarHidden;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return self.statusBarStyle;
}
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
return self.statusBarAnimation;
}
- (void)setRotating:(BOOL)rotating {
_rotating = rotating;
if (!rotating && self.rotatingCompleted) {
self.rotatingCompleted();
}
}
@end

View File

@@ -24,13 +24,12 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ZFLandscapeViewController.h" #import "ZFLandscapeViewController.h"
@class ZFLandscapeRotationManager;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface ZFLandscapeWindow : UIWindow @interface ZFLandscapeWindow : UIWindow
@property (nonatomic, weak) ZFLandscapeRotationManager *rotationManager; @property (nonatomic, strong, readonly) ZFLandscapeViewController *landscapeViewController;
@end @end

View File

@@ -23,7 +23,6 @@
// THE SOFTWARE. // THE SOFTWARE.
#import "ZFLandscapeWindow.h" #import "ZFLandscapeWindow.h"
#import "ZFLandscapeRotationManager_iOS15.h"
@implementation ZFLandscapeWindow @implementation ZFLandscapeWindow
@dynamic rootViewController; @dynamic rootViewController;
@@ -33,16 +32,13 @@
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.windowLevel = UIWindowLevelStatusBar - 1; self.windowLevel = UIWindowLevelNormal;
_landscapeViewController = [[ZFLandscapeViewController alloc] init];
self.rootViewController = _landscapeViewController;
if (@available(iOS 13.0, *)) { if (@available(iOS 13.0, *)) {
if (self.windowScene == nil) { if (self.windowScene == nil) {
self.windowScene = UIApplication.sharedApplication.keyWindow.windowScene; self.windowScene = UIApplication.sharedApplication.keyWindow.windowScene;
} }
if (@available(iOS 9.0, *)) {
[self.rootViewController loadViewIfNeeded];
} else {
[self.rootViewController view];
}
} }
self.hidden = YES; self.hidden = YES;
} }

View File

@@ -50,7 +50,6 @@ typedef NS_ENUM(NSUInteger, ZFRotateType) {
Rotation of support direction Rotation of support direction
*/ */
typedef NS_OPTIONS(NSUInteger, ZFInterfaceOrientationMask) { typedef NS_OPTIONS(NSUInteger, ZFInterfaceOrientationMask) {
ZFInterfaceOrientationMaskUnknow = 0,
ZFInterfaceOrientationMaskPortrait = (1 << 0), ZFInterfaceOrientationMaskPortrait = (1 << 0),
ZFInterfaceOrientationMaskLandscapeLeft = (1 << 1), ZFInterfaceOrientationMaskLandscapeLeft = (1 << 1),
ZFInterfaceOrientationMaskLandscapeRight = (1 << 2), ZFInterfaceOrientationMaskLandscapeRight = (1 << 2),
@@ -84,8 +83,13 @@ typedef NS_OPTIONS(NSUInteger, ZFDisablePortraitGestureTypes) {
- (void)updateRotateView:(ZFPlayerView *)rotateView - (void)updateRotateView:(ZFPlayerView *)rotateView
containerView:(UIView *)containerView; containerView:(UIView *)containerView;
/// list play
- (void)updateRotateView:(ZFPlayerView *)rotateView
rotateViewAtCell:(UIView *)cell
playerViewTag:(NSInteger)playerViewTag;
/// Container view of a full screen state player. /// Container view of a full screen state player.
@property (nonatomic, strong, readonly, nullable) UIView *fullScreenContainerView; @property (nonatomic, strong) UIView *fullScreenContainerView;
/// Container view of a small screen state player. /// Container view of a small screen state player.
@property (nonatomic, weak) UIView *containerView; @property (nonatomic, weak) UIView *containerView;

View File

@@ -27,8 +27,6 @@
#import "ZFPortraitViewController.h" #import "ZFPortraitViewController.h"
#import "ZFPlayerConst.h" #import "ZFPlayerConst.h"
#import <objc/runtime.h> #import <objc/runtime.h>
#import "ZFLandscapeRotationManager_iOS15.h"
#import "ZFLandscapeRotationManager_iOS16.h"
@interface UIWindow (CurrentViewController) @interface UIWindow (CurrentViewController)
@@ -42,7 +40,7 @@
@implementation UIWindow (CurrentViewController) @implementation UIWindow (CurrentViewController)
+ (UIViewController*)zf_currentViewController { + (UIViewController*)zf_currentViewController; {
__block UIWindow *window; __block UIWindow *window;
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
[[UIApplication sharedApplication].connectedScenes enumerateObjectsUsingBlock:^(UIScene * _Nonnull scene, BOOL * _Nonnull scenesStop) { [[UIApplication sharedApplication].connectedScenes enumerateObjectsUsingBlock:^(UIScene * _Nonnull scene, BOOL * _Nonnull scenesStop) {
@@ -78,19 +76,32 @@
@end @end
@interface ZFOrientationObserver () @interface ZFOrientationObserver () <ZFLandscapeViewControllerDelegate>
@property (nonatomic, weak) ZFPlayerView *view; @property (nonatomic, weak) ZFPlayerView *view;
@property (nonatomic, assign, getter=isFullScreen) BOOL fullScreen; @property (nonatomic, assign, getter=isFullScreen) BOOL fullScreen;
@property (nonatomic, strong) ZFPortraitViewController *portraitViewController; @property (nonatomic, strong) UIView *cell;
@property (nonatomic, strong) ZFLandscapeRotationManager *landscapeRotationManager; @property (nonatomic, assign) NSInteger playerViewTag;
@property (nonatomic, assign) ZFRotateType rotateType;
@property (nonatomic, strong) UIWindow *previousKeyWindow;
@property (nonatomic, strong) ZFLandscapeWindow *window;
@property (nonatomic, readonly, getter=isRotating) BOOL rotating;
@property (nonatomic, strong) ZFPortraitViewController *portraitViewController;
/// current device orientation observer is activie. /// current device orientation observer is activie.
@property (nonatomic, assign) BOOL activeDeviceObserver; @property (nonatomic, assign) BOOL activeDeviceObserver;
/// Force Rotaion, default NO.
@property (nonatomic, assign) BOOL forceRotaion;
@end @end
@implementation ZFOrientationObserver @implementation ZFOrientationObserver
@@ -101,22 +112,29 @@
if (self) { if (self) {
_duration = 0.30; _duration = 0.30;
_fullScreenMode = ZFFullScreenModeLandscape; _fullScreenMode = ZFFullScreenModeLandscape;
_supportInterfaceOrientation = ZFInterfaceOrientationMaskAllButUpsideDown;
_allowOrientationRotation = YES;
_rotateType = ZFRotateTypeNormal;
_currentOrientation = UIInterfaceOrientationPortrait;
_portraitFullScreenMode = ZFPortraitFullScreenModeScaleToFill; _portraitFullScreenMode = ZFPortraitFullScreenModeScaleToFill;
_disablePortraitGestureTypes = ZFDisablePortraitGestureTypesAll; _disablePortraitGestureTypes = ZFDisablePortraitGestureTypesAll;
self.supportInterfaceOrientation = ZFInterfaceOrientationMaskAllButUpsideDown;
self.allowOrientationRotation = YES;
self.activeDeviceObserver = YES;
} }
return self; return self;
} }
- (void)updateRotateView:(ZFPlayerView *)rotateView - (void)updateRotateView:(ZFPlayerView *)rotateView
containerView:(UIView *)containerView { containerView:(UIView *)containerView {
self.rotateType = ZFRotateTypeNormal;
self.view = rotateView; self.view = rotateView;
self.containerView = containerView; self.containerView = containerView;
[self.landscapeRotationManager updateRotateView:rotateView containerView:containerView];
} }
- (void)updateRotateView:(ZFPlayerView *)rotateView rotateViewAtCell:(UIView *)cell playerViewTag:(NSInteger)playerViewTag {
self.rotateType = ZFRotateTypeCell;
self.view = rotateView;
self.cell = cell;
self.playerViewTag = playerViewTag;
}
- (void)dealloc { - (void)dealloc {
[self removeDeviceOrientationObserver]; [self removeDeviceOrientationObserver];
@@ -142,7 +160,49 @@
- (void)handleDeviceOrientationChange { - (void)handleDeviceOrientationChange {
if (self.fullScreenMode == ZFFullScreenModePortrait || !self.allowOrientationRotation) return; if (self.fullScreenMode == ZFFullScreenModePortrait || !self.allowOrientationRotation) return;
[self.landscapeRotationManager handleDeviceOrientationChange]; if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) {
return;
}
UIInterfaceOrientation currentOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
// Determine that if the current direction is the same as the direction you want to rotate, do nothing
if (currentOrientation == _currentOrientation) return;
_currentOrientation = currentOrientation;
if (_currentOrientation == UIInterfaceOrientationPortraitUpsideDown) return;
switch (currentOrientation) {
case UIInterfaceOrientationPortrait: {
if ([self _isSupportedPortrait]) {
[self rotateToOrientation:UIInterfaceOrientationPortrait animated:YES];
}
}
break;
case UIInterfaceOrientationLandscapeLeft: {
if ([self _isSupportedLandscapeLeft]) {
[self rotateToOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
}
}
break;
case UIInterfaceOrientationLandscapeRight: {
if ([self _isSupportedLandscapeRight]) {
[self rotateToOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
}
}
break;
default: break;
}
}
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation {
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
UIInterfaceOrientation val = orientation;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
} }
#pragma mark - public #pragma mark - public
@@ -153,7 +213,47 @@
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion { - (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion {
if (self.fullScreenMode == ZFFullScreenModePortrait) return; if (self.fullScreenMode == ZFFullScreenModePortrait) return;
[self.landscapeRotationManager rotateToOrientation:orientation animated:animated completion:completion]; _currentOrientation = orientation;
self.forceRotaion = YES;
if (UIInterfaceOrientationIsLandscape(orientation)) {
if (!self.fullScreen) {
UIView *containerView = nil;
if (self.rotateType == ZFRotateTypeCell) {
containerView = [self.cell viewWithTag:self.playerViewTag];
} else {
containerView = self.containerView;
}
CGRect targetRect = [self.view convertRect:self.view.frame toView:containerView.window];
if (!self.window) {
self.window = [ZFLandscapeWindow new];
self.window.landscapeViewController.delegate = self;
if (@available(iOS 9.0, *)) {
[self.window.rootViewController loadViewIfNeeded];
} else {
[self.window.rootViewController view];
}
}
self.window.landscapeViewController.targetRect = targetRect;
self.window.landscapeViewController.contentView = self.view;
self.window.landscapeViewController.containerView = self.containerView;
self.fullScreen = YES;
}
if (self.orientationWillChange) self.orientationWillChange(self, self.isFullScreen);
} else {
self.fullScreen = NO;
}
self.window.landscapeViewController.disableAnimations = !animated;
@zf_weakify(self)
self.window.landscapeViewController.rotatingCompleted = ^{
@zf_strongify(self)
self.forceRotaion = NO;
if (completion) completion();
};
[self interfaceOrientation:UIInterfaceOrientationUnknown];
[self interfaceOrientation:orientation];
} }
- (void)enterPortraitFullScreen:(BOOL)fullScreen animated:(BOOL)animated { - (void)enterPortraitFullScreen:(BOOL)fullScreen animated:(BOOL)animated {
@@ -184,7 +284,7 @@
} }
- (void)enterFullScreen:(BOOL)fullScreen animated:(BOOL)animated { - (void)enterFullScreen:(BOOL)fullScreen animated:(BOOL)animated {
[self enterFullScreen:fullScreen animated:animated completion:nil]; [self enterFullScreen:fullScreen animated:animated];
} }
- (void)enterFullScreen:(BOOL)fullScreen animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion { - (void)enterFullScreen:(BOOL)fullScreen animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion {
@@ -197,6 +297,128 @@
} }
} }
#pragma mark - private
/// is support portrait
- (BOOL)_isSupportedPortrait {
return self.supportInterfaceOrientation & ZFInterfaceOrientationMaskPortrait;
}
/// is support landscapeLeft
- (BOOL)_isSupportedLandscapeLeft {
return self.supportInterfaceOrientation & ZFInterfaceOrientationMaskLandscapeLeft;
}
/// is support landscapeRight
- (BOOL)_isSupportedLandscapeRight {
return self.supportInterfaceOrientation & ZFInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)_isSupported:(UIInterfaceOrientation)orientation {
switch (orientation) {
case UIInterfaceOrientationPortrait:
return self.supportInterfaceOrientation & ZFInterfaceOrientationMaskPortrait;
case UIInterfaceOrientationLandscapeLeft:
return self.supportInterfaceOrientation & ZFInterfaceOrientationMaskLandscapeLeft;
case UIInterfaceOrientationLandscapeRight:
return self.supportInterfaceOrientation & ZFInterfaceOrientationMaskLandscapeRight;
default:
return NO;
}
return NO;
}
- (void)_rotationToLandscapeOrientation:(UIInterfaceOrientation)orientation {
if (UIInterfaceOrientationIsLandscape(orientation)) {
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
if (keyWindow != self.window && self.previousKeyWindow != keyWindow) {
self.previousKeyWindow = UIApplication.sharedApplication.keyWindow;
}
if (!self.window.isKeyWindow) {
self.window.hidden = NO;
[self.window makeKeyAndVisible];
}
}
}
- (void)_rotationToPortraitOrientation:(UIInterfaceOrientation)orientation {
if (orientation == UIInterfaceOrientationPortrait && !self.window.hidden) {
UIView *containerView = nil;
if (self.rotateType == ZFRotateTypeCell) {
containerView = [self.cell viewWithTag:self.playerViewTag];
} else {
containerView = self.containerView;
}
UIView *snapshot = [self.view snapshotViewAfterScreenUpdates:NO];
snapshot.frame = containerView.bounds;
[containerView addSubview:snapshot];
[self performSelector:@selector(_contentViewAdd:) onThread:NSThread.mainThread withObject:containerView waitUntilDone:NO modes:@[NSDefaultRunLoopMode]];
[self performSelector:@selector(_makeKeyAndVisible:) onThread:NSThread.mainThread withObject:snapshot waitUntilDone:NO modes:@[NSDefaultRunLoopMode]];
}
}
- (void)_contentViewAdd:(UIView *)containerView {
[containerView addSubview:self.view];
self.view.frame = containerView.bounds;
[self.view layoutIfNeeded];
}
- (void)_makeKeyAndVisible:(UIView *)snapshot {
[snapshot removeFromSuperview];
UIWindow *previousKeyWindow = self.previousKeyWindow ?: UIApplication.sharedApplication.windows.firstObject;
[previousKeyWindow makeKeyAndVisible];
self.previousKeyWindow = nil;
self.window.hidden = YES;
}
#pragma mark - ZFLandscapeViewControllerDelegate
- (BOOL)ls_shouldAutorotate {
if (self.fullScreenMode == ZFFullScreenModePortrait) {
return NO;
}
UIInterfaceOrientation currentOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
if (![self _isSupported:currentOrientation]) {
return NO;
}
if (self.forceRotaion) {
[self _rotationToLandscapeOrientation:currentOrientation];
return YES;
}
if (!self.activeDeviceObserver) {
return NO;
}
[self _rotationToLandscapeOrientation:currentOrientation];
return YES;
}
- (void)ls_willRotateToOrientation:(UIInterfaceOrientation)orientation {
self.fullScreen = UIInterfaceOrientationIsLandscape(orientation);
if (self.orientationWillChange) self.orientationWillChange(self, self.isFullScreen);
}
- (void)ls_didRotateFromOrientation:(UIInterfaceOrientation)orientation {
if (self.orientationDidChanged) self.orientationDidChanged(self, self.isFullScreen);
if (!self.isFullScreen) {
[self _rotationToPortraitOrientation:UIInterfaceOrientationPortrait];
}
}
- (CGRect)ls_targetRect {
UIView *containerView = nil;
if (self.rotateType == ZFRotateTypeCell) {
containerView = [self.cell viewWithTag:self.playerViewTag];
} else {
containerView = self.containerView;
}
CGRect targetRect = [containerView convertRect:containerView.bounds toView:containerView.window];
return targetRect;
}
#pragma mark - getter #pragma mark - getter
- (ZFPortraitViewController *)portraitViewController { - (ZFPortraitViewController *)portraitViewController {
@@ -222,50 +444,10 @@
return _portraitViewController; return _portraitViewController;
} }
- (ZFLandscapeRotationManager *)landscapeRotationManager {
if (!_landscapeRotationManager) {
if (@available(iOS 16.0, *)) {
_landscapeRotationManager = [[ZFLandscapeRotationManager_iOS16 alloc] init];
} else {
_landscapeRotationManager = [[ZFLandscapeRotationManager_iOS15 alloc] init];
}
@zf_weakify(self)
_landscapeRotationManager.orientationWillChange = ^(UIInterfaceOrientation orientation) {
@zf_strongify(self)
self.fullScreen = UIInterfaceOrientationIsLandscape(orientation);
if (self.orientationWillChange) self.orientationWillChange(self, self.fullScreen);
};
_landscapeRotationManager.orientationDidChanged = ^(UIInterfaceOrientation orientation) {
@zf_strongify(self)
self.fullScreen = UIInterfaceOrientationIsLandscape(orientation);
if (self.orientationDidChanged) self.orientationDidChanged(self, self.fullScreen);
};
}
return _landscapeRotationManager;
}
- (UIView *)fullScreenContainerView {
if (self.fullScreenMode == ZFFullScreenModeLandscape) {
return self.landscapeRotationManager.landscapeViewController.view;
} else if (self.fullScreenMode == ZFFullScreenModePortrait) {
return self.portraitViewController.view;
}
return nil;
}
- (UIInterfaceOrientation)currentOrientation {
if (self.fullScreenMode == ZFFullScreenModeLandscape) {
return self.landscapeRotationManager.currentOrientation;
}
return [self.landscapeRotationManager getCurrentOrientation];
}
#pragma mark - setter #pragma mark - setter
- (void)setLockedScreen:(BOOL)lockedScreen { - (void)setLockedScreen:(BOOL)lockedScreen {
_lockedScreen = lockedScreen; _lockedScreen = lockedScreen;
self.landscapeRotationManager.lockedScreen = lockedScreen;
if (lockedScreen) { if (lockedScreen) {
[self removeDeviceOrientationObserver]; [self removeDeviceOrientationObserver];
} else { } else {
@@ -273,9 +455,18 @@
} }
} }
- (UIView *)fullScreenContainerView {
if (self.fullScreenMode == ZFFullScreenModeLandscape) {
return self.window.landscapeViewController.view;
} else if (self.fullScreenMode == ZFFullScreenModePortrait) {
return self.portraitViewController.view;
}
return nil;
}
- (void)setFullScreen:(BOOL)fullScreen { - (void)setFullScreen:(BOOL)fullScreen {
_fullScreen = fullScreen; _fullScreen = fullScreen;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate]; [self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
[UIViewController attemptRotationToDeviceOrientation]; [UIViewController attemptRotationToDeviceOrientation];
} }
@@ -285,8 +476,8 @@
self.portraitViewController.statusBarHidden = fullScreenStatusBarHidden; self.portraitViewController.statusBarHidden = fullScreenStatusBarHidden;
[self.portraitViewController setNeedsStatusBarAppearanceUpdate]; [self.portraitViewController setNeedsStatusBarAppearanceUpdate];
} else if (self.fullScreenMode == ZFFullScreenModeLandscape) { } else if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.landscapeViewController.statusBarHidden = fullScreenStatusBarHidden; self.window.landscapeViewController.statusBarHidden = fullScreenStatusBarHidden;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate]; [self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
} }
} }
@@ -296,8 +487,8 @@
self.portraitViewController.statusBarStyle = fullScreenStatusBarStyle; self.portraitViewController.statusBarStyle = fullScreenStatusBarStyle;
[self.portraitViewController setNeedsStatusBarAppearanceUpdate]; [self.portraitViewController setNeedsStatusBarAppearanceUpdate];
} else if (self.fullScreenMode == ZFFullScreenModeLandscape) { } else if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.landscapeViewController.statusBarStyle = fullScreenStatusBarStyle; self.window.landscapeViewController.statusBarStyle = fullScreenStatusBarStyle;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate]; [self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
} }
} }
@@ -307,8 +498,8 @@
self.portraitViewController.statusBarAnimation = fullScreenStatusBarAnimation; self.portraitViewController.statusBarAnimation = fullScreenStatusBarAnimation;
[self.portraitViewController setNeedsStatusBarAppearanceUpdate]; [self.portraitViewController setNeedsStatusBarAppearanceUpdate];
} else if (self.fullScreenMode == ZFFullScreenModeLandscape) { } else if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.landscapeViewController.statusBarAnimation = fullScreenStatusBarAnimation; self.window.landscapeViewController.statusBarAnimation = fullScreenStatusBarAnimation;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate]; [self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
} }
} }
@@ -325,20 +516,24 @@
} }
- (void)setView:(ZFPlayerView *)view { - (void)setView:(ZFPlayerView *)view {
if (view == _view) { return; } if (view == _view) {
return;
}
_view = view; _view = view;
if (self.fullScreenMode == ZFFullScreenModeLandscape) { if (self.fullScreenMode == ZFFullScreenModeLandscape && self.window) {
self.landscapeRotationManager.contentView = view; self.window.landscapeViewController.contentView = view;
} else if (self.fullScreenMode == ZFFullScreenModePortrait) { } else if (self.fullScreenMode == ZFFullScreenModePortrait) {
self.portraitViewController.contentView = view; self.portraitViewController.contentView = view;
} }
} }
- (void)setContainerView:(UIView *)containerView { - (void)setContainerView:(UIView *)containerView {
if (containerView == _containerView) { return; } if (containerView == _containerView) {
return;
}
_containerView = containerView; _containerView = containerView;
if (self.fullScreenMode == ZFFullScreenModeLandscape) { if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.containerView = containerView; self.window.landscapeViewController.containerView = containerView;
} else if (self.fullScreenMode == ZFFullScreenModePortrait) { } else if (self.fullScreenMode == ZFFullScreenModePortrait) {
self.portraitViewController.containerView = containerView; self.portraitViewController.containerView = containerView;
} }
@@ -346,17 +541,11 @@
- (void)setAllowOrientationRotation:(BOOL)allowOrientationRotation { - (void)setAllowOrientationRotation:(BOOL)allowOrientationRotation {
_allowOrientationRotation = allowOrientationRotation; _allowOrientationRotation = allowOrientationRotation;
self.landscapeRotationManager.allowOrientationRotation = allowOrientationRotation; if (allowOrientationRotation) {
} [self addDeviceOrientationObserver];
} else {
- (void)setSupportInterfaceOrientation:(ZFInterfaceOrientationMask)supportInterfaceOrientation { [self removeDeviceOrientationObserver];
_supportInterfaceOrientation = supportInterfaceOrientation; }
self.landscapeRotationManager.supportInterfaceOrientation = supportInterfaceOrientation;
}
- (void)setActiveDeviceObserver:(BOOL)activeDeviceObserver {
_activeDeviceObserver = activeDeviceObserver;
self.landscapeRotationManager.activeDeviceObserver = activeDeviceObserver;
} }
@end @end

View File

@@ -37,28 +37,26 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZFPlayerController : NSObject @interface ZFPlayerController : NSObject
/// The video contrainerView in normal model. /// The video contrainerView in normal model.
@property (nonatomic, weak, nullable) UIView *containerView; @property (nonatomic, strong) UIView *containerView;
/// The currentPlayerManager must conform `ZFPlayerMediaPlayback` protocol. /// The currentPlayerManager must conform `ZFPlayerMediaPlayback` protocol.
@property (nonatomic, strong) id<ZFPlayerMediaPlayback> currentPlayerManager; @property (nonatomic, strong) id<ZFPlayerMediaPlayback> currentPlayerManager;
/// The custom controlView must conform `ZFPlayerMediaControl` protocol. /// The custom controlView must conform `ZFPlayerMediaControl` protocol.
@property (nonatomic, strong, nullable) UIView<ZFPlayerMediaControl> *controlView; @property (nonatomic, strong) UIView<ZFPlayerMediaControl> *controlView;
/// The notification manager class. /// The notification manager class.
@property (nonatomic, strong, readonly, nullable) ZFPlayerNotification *notification; @property (nonatomic, strong, readonly) ZFPlayerNotification *notification;
/// The container view type. /// The container view type.
@property (nonatomic, assign, readonly) ZFPlayerContainerType containerType; @property (nonatomic, assign, readonly) ZFPlayerContainerType containerType;
/// The player's small container view. /// The player's small container view.
@property (nonatomic, strong, readonly, nullable) ZFFloatView *smallFloatView; @property (nonatomic, strong, readonly) ZFFloatView *smallFloatView;
/// Whether the small window is displayed. /// Whether the small window is displayed.
@property (nonatomic, assign, readonly) BOOL isSmallFloatViewShow; @property (nonatomic, assign, readonly) BOOL isSmallFloatViewShow;
/// The scroll view is `tableView` or `collectionView`.
@property (nonatomic, weak, nullable) UIScrollView *scrollView;
/*! /*!
@method playerWithPlayerManager:containerView: @method playerWithPlayerManager:containerView:
@abstract Create an ZFPlayerController that plays a single audiovisual item. @abstract Create an ZFPlayerController that plays a single audiovisual item.
@@ -164,7 +162,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) float brightness; @property (nonatomic) float brightness;
/// The play asset URL. /// The play asset URL.
@property (nonatomic, nullable) NSURL *assetURL; @property (nonatomic) NSURL *assetURL;
/// If tableView or collectionView has only one section , use `assetURLs`. /// If tableView or collectionView has only one section , use `assetURLs`.
/// If tableView or collectionView has more sections , use `sectionAssetURLs`. /// If tableView or collectionView has more sections , use `sectionAssetURLs`.
@@ -302,6 +300,10 @@ NS_ASSUME_NONNULL_BEGIN
/// Lock the screen orientation. /// Lock the screen orientation.
@property (nonatomic, getter=isLockedScreen) BOOL lockedScreen; @property (nonatomic, getter=isLockedScreen) BOOL lockedScreen;
/// The current orientation of the player.
/// Default is UIInterfaceOrientationPortrait.
@property (nonatomic, readonly) UIInterfaceOrientation currentOrientation;
/// The block invoked When player will rotate. /// The block invoked When player will rotate.
@property (nonatomic, copy, nullable) void(^orientationWillChange)(ZFPlayerController *player, BOOL isFullScreen); @property (nonatomic, copy, nullable) void(^orientationWillChange)(ZFPlayerController *player, BOOL isFullScreen);
@@ -395,6 +397,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZFPlayerController (ZFPlayerScrollView) @interface ZFPlayerController (ZFPlayerScrollView)
/// The scroll view is `tableView` or `collectionView`.
@property (nonatomic, readonly, nullable) UIScrollView *scrollView;
/// The scrollView player should auto player, default is YES. /// The scrollView player should auto player, default is YES.
@property (nonatomic) BOOL shouldAutoPlay; @property (nonatomic) BOOL shouldAutoPlay;

View File

@@ -35,6 +35,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
@interface ZFPlayerController () @interface ZFPlayerController ()
@property (nonatomic, strong) ZFPlayerNotification *notification; @property (nonatomic, strong) ZFPlayerNotification *notification;
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic, strong) UISlider *volumeViewSlider; @property (nonatomic, strong) UISlider *volumeViewSlider;
@property (nonatomic, assign) NSInteger containerViewTag; @property (nonatomic, assign) NSInteger containerViewTag;
@property (nonatomic, assign) ZFPlayerContainerType containerType; @property (nonatomic, assign) ZFPlayerContainerType containerType;
@@ -49,6 +50,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
@implementation ZFPlayerController @implementation ZFPlayerController
@dynamic scrollView;
@dynamic containerViewTag; @dynamic containerViewTag;
@dynamic playingIndexPath; @dynamic playingIndexPath;
@@ -348,111 +350,6 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
} }
} }
- (void)setScrollView:(UIScrollView *)scrollView {
_scrollView = scrollView;
self.scrollView.zf_WWANAutoPlay = self.isWWANAutoPlay;
@zf_weakify(self)
scrollView.zf_playerWillAppearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerWillAppearInScrollView) self.zf_playerWillAppearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerDidAppearInScrollView:)]) {
[self.controlView playerDidAppearInScrollView:self];
}
};
scrollView.zf_playerDidAppearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerDidAppearInScrollView) self.zf_playerDidAppearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerDidAppearInScrollView:)]) {
[self.controlView playerDidAppearInScrollView:self];
}
};
scrollView.zf_playerWillDisappearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerWillDisappearInScrollView) self.zf_playerWillDisappearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerWillDisappearInScrollView:)]) {
[self.controlView playerWillDisappearInScrollView:self];
}
};
scrollView.zf_playerDidDisappearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerDidDisappearInScrollView) self.zf_playerDidDisappearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerDidDisappearInScrollView:)]) {
[self.controlView playerDidDisappearInScrollView:self];
}
if (self.stopWhileNotVisible) { /// stop playing
if (self.containerType == ZFPlayerContainerTypeView) {
[self stopCurrentPlayingView];
} else if (self.containerType == ZFPlayerContainerTypeCell) {
[self stopCurrentPlayingCell];
}
} else { /// add to window
if (!self.isSmallFloatViewShow) {
[self addPlayerViewToSmallFloatView];
}
}
};
scrollView.zf_playerAppearingInScrollView = ^(NSIndexPath * _Nonnull indexPath, CGFloat playerApperaPercent) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerAppearingInScrollView) self.zf_playerAppearingInScrollView(indexPath, playerApperaPercent);
if ([self.controlView respondsToSelector:@selector(playerAppearingInScrollView:playerApperaPercent:)]) {
[self.controlView playerAppearingInScrollView:self playerApperaPercent:playerApperaPercent];
}
if (!self.stopWhileNotVisible && playerApperaPercent >= self.playerApperaPercent) {
if (self.containerType == ZFPlayerContainerTypeView) {
if (self.isSmallFloatViewShow) {
[self addPlayerViewToContainerView:self.containerView];
}
} else if (self.containerType == ZFPlayerContainerTypeCell) {
if (self.isSmallFloatViewShow) {
[self addPlayerViewToCell];
}
}
}
};
scrollView.zf_playerDisappearingInScrollView = ^(NSIndexPath * _Nonnull indexPath, CGFloat playerDisapperaPercent) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerDisappearingInScrollView) self.zf_playerDisappearingInScrollView(indexPath, playerDisapperaPercent);
if ([self.controlView respondsToSelector:@selector(playerDisappearingInScrollView:playerDisapperaPercent:)]) {
[self.controlView playerDisappearingInScrollView:self playerDisapperaPercent:playerDisapperaPercent];
}
if (playerDisapperaPercent >= self.playerDisapperaPercent) {
if (self.stopWhileNotVisible) { /// stop playing
if (self.containerType == ZFPlayerContainerTypeView) {
[self stopCurrentPlayingView];
} else if (self.containerType == ZFPlayerContainerTypeCell) {
[self stopCurrentPlayingCell];
}
} else { /// add to window
if (!self.isSmallFloatViewShow) {
[self addPlayerViewToSmallFloatView];
}
}
}
};
scrollView.zf_playerShouldPlayInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.zf_playerShouldPlayInScrollView) self.zf_playerShouldPlayInScrollView(indexPath);
};
scrollView.zf_scrollViewDidEndScrollingCallback = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.zf_scrollViewDidEndScrollingCallback) self.zf_scrollViewDidEndScrollingCallback(indexPath);
};
}
@end @end
@implementation ZFPlayerController (ZFPlayerTimeControl) @implementation ZFPlayerController (ZFPlayerTimeControl)
@@ -528,7 +425,6 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
[self.currentPlayerManager stop]; [self.currentPlayerManager stop];
[self.currentPlayerManager.view removeFromSuperview]; [self.currentPlayerManager.view removeFromSuperview];
} }
self.lockedScreen = NO;
if (self.scrollView) self.scrollView.zf_stopPlay = YES; if (self.scrollView) self.scrollView.zf_stopPlay = YES;
[self.notification removeNotification]; [self.notification removeNotification];
[self.orientationObserver removeDeviceOrientationObserver]; [self.orientationObserver removeDeviceOrientationObserver];
@@ -538,7 +434,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
self.currentPlayerManager = playerManager; self.currentPlayerManager = playerManager;
} }
/// Add video to the cell //// Add video to the cell
- (void)addPlayerViewToCell { - (void)addPlayerViewToCell {
self.isSmallFloatViewShow = NO; self.isSmallFloatViewShow = NO;
self.smallFloatView.hidden = YES; self.smallFloatView.hidden = YES;
@@ -547,10 +443,10 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
[self.containerView addSubview:self.currentPlayerManager.view]; [self.containerView addSubview:self.currentPlayerManager.view];
self.currentPlayerManager.view.frame = self.containerView.bounds; self.currentPlayerManager.view.frame = self.containerView.bounds;
self.currentPlayerManager.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.currentPlayerManager.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.orientationObserver updateRotateView:self.currentPlayerManager.view rotateViewAtCell:cell playerViewTag:self.containerViewTag];
if ([self.controlView respondsToSelector:@selector(videoPlayer:floatViewShow:)]) { if ([self.controlView respondsToSelector:@selector(videoPlayer:floatViewShow:)]) {
[self.controlView videoPlayer:self floatViewShow:NO]; [self.controlView videoPlayer:self floatViewShow:NO];
} }
[self layoutPlayerSubViews];
} }
//// Add video to the container view //// Add video to the container view
@@ -847,7 +743,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
/// Enter the fullScreen while the ZFFullScreenMode is ZFFullScreenModeLandscape. /// Enter the fullScreen while the ZFFullScreenMode is ZFFullScreenModeLandscape.
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion { - (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion {
self.orientationObserver.fullScreenMode = ZFFullScreenModeLandscape; self.orientationObserver.fullScreenMode = ZFFullScreenModeLandscape;
[self.orientationObserver rotateToOrientation:orientation animated:animated completion:completion]; [self.orientationObserver rotateToOrientation:orientation animated:animated completion:nil];
} }
- (void)enterPortraitFullScreen:(BOOL)fullScreen animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion { - (void)enterPortraitFullScreen:(BOOL)fullScreen animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion {
@@ -920,6 +816,10 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
return YES; return YES;
} }
- (UIInterfaceOrientation)currentOrientation {
return self.orientationObserver.currentOrientation;
}
- (BOOL)isStatusBarHidden { - (BOOL)isStatusBarHidden {
return [objc_getAssociatedObject(self, _cmd) boolValue]; return [objc_getAssociatedObject(self, _cmd) boolValue];
} }
@@ -1114,6 +1014,111 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
#pragma mark - setter #pragma mark - setter
- (void)setScrollView:(UIScrollView *)scrollView {
objc_setAssociatedObject(self, @selector(scrollView), scrollView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
self.scrollView.zf_WWANAutoPlay = self.isWWANAutoPlay;
@zf_weakify(self)
scrollView.zf_playerWillAppearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerWillAppearInScrollView) self.zf_playerWillAppearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerDidAppearInScrollView:)]) {
[self.controlView playerDidAppearInScrollView:self];
}
};
scrollView.zf_playerDidAppearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerDidAppearInScrollView) self.zf_playerDidAppearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerDidAppearInScrollView:)]) {
[self.controlView playerDidAppearInScrollView:self];
}
};
scrollView.zf_playerWillDisappearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerWillDisappearInScrollView) self.zf_playerWillDisappearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerWillDisappearInScrollView:)]) {
[self.controlView playerWillDisappearInScrollView:self];
}
};
scrollView.zf_playerDidDisappearInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerDidDisappearInScrollView) self.zf_playerDidDisappearInScrollView(indexPath);
if ([self.controlView respondsToSelector:@selector(playerDidDisappearInScrollView:)]) {
[self.controlView playerDidDisappearInScrollView:self];
}
if (self.stopWhileNotVisible) { /// stop playing
if (self.containerType == ZFPlayerContainerTypeView) {
[self stopCurrentPlayingView];
} else if (self.containerType == ZFPlayerContainerTypeCell) {
[self stopCurrentPlayingCell];
}
} else { /// add to window
if (!self.isSmallFloatViewShow) {
[self addPlayerViewToSmallFloatView];
}
}
};
scrollView.zf_playerAppearingInScrollView = ^(NSIndexPath * _Nonnull indexPath, CGFloat playerApperaPercent) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerAppearingInScrollView) self.zf_playerAppearingInScrollView(indexPath, playerApperaPercent);
if ([self.controlView respondsToSelector:@selector(playerAppearingInScrollView:playerApperaPercent:)]) {
[self.controlView playerAppearingInScrollView:self playerApperaPercent:playerApperaPercent];
}
if (!self.stopWhileNotVisible && playerApperaPercent >= self.playerApperaPercent) {
if (self.containerType == ZFPlayerContainerTypeView) {
if (self.isSmallFloatViewShow) {
[self addPlayerViewToContainerView:self.containerView];
}
} else if (self.containerType == ZFPlayerContainerTypeCell) {
if (self.isSmallFloatViewShow) {
[self addPlayerViewToCell];
}
}
}
};
scrollView.zf_playerDisappearingInScrollView = ^(NSIndexPath * _Nonnull indexPath, CGFloat playerDisapperaPercent) {
@zf_strongify(self)
if (self.isFullScreen) return;
if (self.zf_playerDisappearingInScrollView) self.zf_playerDisappearingInScrollView(indexPath, playerDisapperaPercent);
if ([self.controlView respondsToSelector:@selector(playerDisappearingInScrollView:playerDisapperaPercent:)]) {
[self.controlView playerDisappearingInScrollView:self playerDisapperaPercent:playerDisapperaPercent];
}
if (playerDisapperaPercent >= self.playerDisapperaPercent) {
if (self.stopWhileNotVisible) { /// stop playing
if (self.containerType == ZFPlayerContainerTypeView) {
[self stopCurrentPlayingView];
} else if (self.containerType == ZFPlayerContainerTypeCell) {
[self stopCurrentPlayingCell];
}
} else { /// add to window
if (!self.isSmallFloatViewShow) {
[self addPlayerViewToSmallFloatView];
}
}
}
};
scrollView.zf_playerShouldPlayInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.zf_playerShouldPlayInScrollView) self.zf_playerShouldPlayInScrollView(indexPath);
};
scrollView.zf_scrollViewDidEndScrollingCallback = ^(NSIndexPath * _Nonnull indexPath) {
@zf_strongify(self)
if (self.zf_scrollViewDidEndScrollingCallback) self.zf_scrollViewDidEndScrollingCallback(indexPath);
};
}
- (void)setWWANAutoPlay:(BOOL)WWANAutoPlay { - (void)setWWANAutoPlay:(BOOL)WWANAutoPlay {
objc_setAssociatedObject(self, @selector(isWWANAutoPlay), @(WWANAutoPlay), OBJC_ASSOCIATION_RETAIN_NONATOMIC); objc_setAssociatedObject(self, @selector(isWWANAutoPlay), @(WWANAutoPlay), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if (self.scrollView) self.scrollView.zf_WWANAutoPlay = self.isWWANAutoPlay; if (self.scrollView) self.scrollView.zf_WWANAutoPlay = self.isWWANAutoPlay;
@@ -1137,6 +1142,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
UIView *cell = [self.scrollView zf_getCellForIndexPath:playingIndexPath]; UIView *cell = [self.scrollView zf_getCellForIndexPath:playingIndexPath];
self.containerView = [cell viewWithTag:self.containerViewTag]; self.containerView = [cell viewWithTag:self.containerViewTag];
[self.orientationObserver updateRotateView:self.currentPlayerManager.view rotateViewAtCell:cell playerViewTag:self.containerViewTag];
[self addDeviceOrientationObserver]; [self addDeviceOrientationObserver];
self.scrollView.zf_playingIndexPath = playingIndexPath; self.scrollView.zf_playingIndexPath = playingIndexPath;
[self layoutPlayerSubViews]; [self layoutPlayerSubViews];
@@ -1200,6 +1206,11 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
#pragma mark - getter #pragma mark - getter
- (UIScrollView *)scrollView {
UIScrollView *scrollView = objc_getAssociatedObject(self, _cmd);
return scrollView;
}
- (BOOL)isWWANAutoPlay { - (BOOL)isWWANAutoPlay {
return [objc_getAssociatedObject(self, _cmd) boolValue]; return [objc_getAssociatedObject(self, _cmd) boolValue];
} }
@@ -1361,6 +1372,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
if (self.currentPlayerManager.view && self.playingIndexPath && self.containerViewTag) { if (self.currentPlayerManager.view && self.playingIndexPath && self.containerViewTag) {
UIView *cell = [self.scrollView zf_getCellForIndexPath:self.playingIndexPath]; UIView *cell = [self.scrollView zf_getCellForIndexPath:self.playingIndexPath];
self.containerView = [cell viewWithTag:self.containerViewTag]; self.containerView = [cell viewWithTag:self.containerViewTag];
[self.orientationObserver updateRotateView:self.currentPlayerManager.view rotateViewAtCell:cell playerViewTag:self.containerViewTag];
[self layoutPlayerSubViews]; [self layoutPlayerSubViews];
} }
} }

View File

@@ -156,7 +156,7 @@
_doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; _doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
_doubleTap.delegate = self; _doubleTap.delegate = self;
_doubleTap.delaysTouchesBegan = YES; _doubleTap.delaysTouchesBegan = YES;
_doubleTap.delaysTouchesEnded = YES; _singleTap.delaysTouchesEnded = YES;
_doubleTap.numberOfTouchesRequired = 1; _doubleTap.numberOfTouchesRequired = 1;
_doubleTap.numberOfTapsRequired = 2; _doubleTap.numberOfTapsRequired = 2;
} }

View File

@@ -37,7 +37,7 @@ static BOOL kLogEnable = NO;
} }
+ (NSString *)version { + (NSString *)version {
return @"4.1.2"; return @"4.0.2";
} }
+ (void)logWithFunction:(const char *)function lineNumber:(int)lineNumber formatString:(NSString *)formatString { + (void)logWithFunction:(const char *)function lineNumber:(int)lineNumber formatString:(NSString *)formatString {

View File

@@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) BOOL shouldAutoPlay; @property (nonatomic) BOOL shouldAutoPlay;
/// The play asset URL. /// The play asset URL.
@property (nonatomic, nullable) NSURL *assetURL; @property (nonatomic) NSURL *assetURL;
/// The video size. /// The video size.
@property (nonatomic) CGSize presentationSize; @property (nonatomic) CGSize presentationSize;

View File

@@ -55,8 +55,8 @@
CGFloat min_y = 0; CGFloat min_y = 0;
CGFloat min_w = 0; CGFloat min_w = 0;
CGFloat min_h = 0; CGFloat min_h = 0;
CGFloat min_view_w = self.bounds.size.width; CGFloat min_view_w = self.frame.size.width;
CGFloat min_view_h = self.bounds.size.height; CGFloat min_view_h = self.frame.size.height;
CGSize playerViewSize = CGSizeZero; CGSize playerViewSize = CGSizeZero;
CGFloat videoWidth = self.presentationSize.width; CGFloat videoWidth = self.presentationSize.width;

View File

@@ -33,7 +33,6 @@ typedef NS_ENUM(NSInteger, ZFReachabilityStatus) {
ZFReachabilityStatusReachableVia2G = 2, ZFReachabilityStatusReachableVia2G = 2,
ZFReachabilityStatusReachableVia3G = 3, ZFReachabilityStatusReachableVia3G = 3,
ZFReachabilityStatusReachableVia4G = 4, ZFReachabilityStatusReachableVia4G = 4,
ZFReachabilityStatusReachableVia5G = 5
}; };
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@@ -45,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ ) See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
@warning Instances of `ZFReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
*/ */
@interface ZFReachabilityManager : NSObject @interface ZFReachabilityManager : NSObject

View File

@@ -48,8 +48,6 @@ NSString * ZFStringFromNetworkReachabilityStatus(ZFReachabilityStatus status) {
return NSLocalizedStringFromTable(@"Reachable via 3G", @"ZFPlayer", nil); return NSLocalizedStringFromTable(@"Reachable via 3G", @"ZFPlayer", nil);
case ZFReachabilityStatusReachableVia4G: case ZFReachabilityStatusReachableVia4G:
return NSLocalizedStringFromTable(@"Reachable via 4G", @"ZFPlayer", nil); return NSLocalizedStringFromTable(@"Reachable via 4G", @"ZFPlayer", nil);
case ZFReachabilityStatusReachableVia5G:
return NSLocalizedStringFromTable(@"Reachable via 5G", @"ZFPlayer", nil);
case ZFReachabilityStatusUnknown: case ZFReachabilityStatusUnknown:
default: default:
return NSLocalizedStringFromTable(@"Unknown", @"ZFPlayer", nil); return NSLocalizedStringFromTable(@"Unknown", @"ZFPlayer", nil);
@@ -71,36 +69,13 @@ static ZFReachabilityStatus ZFReachabilityStatusForFlags(SCNetworkReachabilityFl
else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
CTTelephonyNetworkInfo * info = [[CTTelephonyNetworkInfo alloc] init]; CTTelephonyNetworkInfo * info = [[CTTelephonyNetworkInfo alloc] init];
NSString *currentRadioAccessTechnology = info.currentRadioAccessTechnology; NSString *currentRadioAccessTechnology = info.currentRadioAccessTechnology;
if (@available(iOS 12.1, *)) {
if (info && [info respondsToSelector:@selector(serviceCurrentRadioAccessTechnology)]) {
NSDictionary *radioDic = [info serviceCurrentRadioAccessTechnology];
if (radioDic.allKeys.count) {
currentRadioAccessTechnology = [radioDic objectForKey:radioDic.allKeys[0]];
}
}
}
if (currentRadioAccessTechnology) { if (currentRadioAccessTechnology) {
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge] if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
status = ZFReachabilityStatusReachableVia2G;
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
status = ZFReachabilityStatusReachableVia3G;
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
status = ZFReachabilityStatusReachableVia4G; status = ZFReachabilityStatusReachableVia4G;
} else if (@available(iOS 14.1, *)) { } else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge] || [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA] status = ZFReachabilityStatusReachableVia2G;
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
status = ZFReachabilityStatusReachableVia5G;
}
} else { } else {
status = ZFReachabilityStatusUnknown; status = ZFReachabilityStatusReachableVia3G;
} }
} }
} }
@@ -132,7 +107,7 @@ static void ZFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, ZFR
}); });
} }
static void ZFPlayerReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
ZFPostReachabilityStatusChange(flags, (__bridge ZFReachabilityStatusBlock)info); ZFPostReachabilityStatusChange(flags, (__bridge ZFReachabilityStatusBlock)info);
} }
@@ -250,7 +225,7 @@ static void ZFReachabilityReleaseCallback(const void *info) {
}; };
SCNetworkReachabilityContext context = {0, (__bridge void *)callback, ZFReachabilityRetainCallback, ZFReachabilityReleaseCallback, NULL}; SCNetworkReachabilityContext context = {0, (__bridge void *)callback, ZFReachabilityRetainCallback, ZFReachabilityReleaseCallback, NULL};
SCNetworkReachabilitySetCallback(self.networkReachability, ZFPlayerReachabilityCallback, &context); SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/UIScrollView+ZFPlayer.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFFloatView.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFKVOController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFLandscapeViewController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFLandscapeWindow.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFOrientationObserver.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPersentInteractiveTransition.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayer.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerConst.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerGestureControl.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerLogManager.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerMediaControl.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerMediaPlayback.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerNotification.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerView.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPortraitViewController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPresentTransition.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFReachabilityManager.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/UIScrollView+ZFPlayer.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFFloatView.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFKVOController.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFLandscapeRotationManager.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFLandscapeRotationManager_iOS15.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFLandscapeRotationManager_iOS16.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFLandscapeViewController.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFLandscapeViewController_iOS15.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFLandscapeWindow.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFOrientationObserver.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPersentInteractiveTransition.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayer.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerConst.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerController.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerGestureControl.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerLogManager.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerMediaControl.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerMediaPlayback.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerNotification.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPlayerView.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPortraitViewController.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFPresentTransition.h

View File

@@ -1 +0,0 @@
../../../ZFPlayer/ZFPlayer/Classes/Core/ZFReachabilityManager.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/UIScrollView+ZFPlayer.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFFloatView.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFKVOController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFLandscapeViewController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFLandscapeWindow.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFOrientationObserver.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPersentInteractiveTransition.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayer.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerConst.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerGestureControl.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerLogManager.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerMediaControl.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerMediaPlayback.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerNotification.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPlayerView.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPortraitViewController.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFPresentTransition.h

View File

@@ -0,0 +1 @@
../../../DDZFPlayerKit_Private/DDZFPlayerKit_Private/Classes/Core/ZFReachabilityManager.h

Some files were not shown because too many files have changed in this diff Show More