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

@@ -453,7 +453,7 @@ Scroll to indexPath with position.
}];
// 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)) {
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIView *playerView = [cell viewWithTag:self.zf_containerViewTag];
@@ -558,7 +558,7 @@ Scroll to indexPath with position.
}];
// 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)) {
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UIView *playerView = [cell viewWithTag:self.zf_containerViewTag];

View File

@@ -23,27 +23,6 @@
#import <UIKit/UIKit.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)
@@ -57,35 +36,17 @@ API_AVAILABLE(ios(13.0)) @implementation UIViewController (ZFPlayerFixSafeArea)
for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) {
SEL originalSelector = selectors[index];
SEL swizzledSelector = NSSelectorFromString([@"zf_" stringByAppendingString:NSStringFromSelector(originalSelector)]);
[self hookClass:self.class originalSelector:originalSelector swizzledSelector:swizzledSelector];
}
double systemVersion = [UIDevice currentDevice].systemVersion.doubleValue;
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];
Method originalMethod = class_getInstanceMethod(self, originalSelector);
Method swizzledMethod = class_getInstanceMethod(self, swizzledSelector);
if (class_addMethod(self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) {
class_replaceMethod(self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
});
}
+ (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 {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
- (NSInteger)zf_selectedIndex {
NSInteger index = [self zf_selectedIndex];
if (index > self.viewControllers.count) return 0;

View File

@@ -28,16 +28,28 @@
NS_ASSUME_NONNULL_BEGIN
@protocol ZFLandscapeViewControllerDelegate <NSObject>
@optional
- (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
@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, readonly) BOOL isFullscreen;
@property (nonatomic, getter=isRotating) BOOL rotating;
@property (nonatomic, assign) BOOL disableAnimations;
@property (nonatomic, assign) BOOL statusBarHidden;
@@ -46,6 +58,8 @@ NS_ASSUME_NONNULL_BEGIN
/// defalut is UIStatusBarAnimationSlide.
@property (nonatomic, assign) UIStatusBarAnimation statusBarAnimation;
@property (nonatomic, copy) void(^rotatingCompleted)(void);
@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 "ZFLandscapeViewController.h"
@class ZFLandscapeRotationManager;
NS_ASSUME_NONNULL_BEGIN
@interface ZFLandscapeWindow : UIWindow
@property (nonatomic, weak) ZFLandscapeRotationManager *rotationManager;
@property (nonatomic, strong, readonly) ZFLandscapeViewController *landscapeViewController;
@end

View File

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

View File

@@ -50,7 +50,6 @@ typedef NS_ENUM(NSUInteger, ZFRotateType) {
Rotation of support direction
*/
typedef NS_OPTIONS(NSUInteger, ZFInterfaceOrientationMask) {
ZFInterfaceOrientationMaskUnknow = 0,
ZFInterfaceOrientationMaskPortrait = (1 << 0),
ZFInterfaceOrientationMaskLandscapeLeft = (1 << 1),
ZFInterfaceOrientationMaskLandscapeRight = (1 << 2),
@@ -84,8 +83,13 @@ typedef NS_OPTIONS(NSUInteger, ZFDisablePortraitGestureTypes) {
- (void)updateRotateView:(ZFPlayerView *)rotateView
containerView:(UIView *)containerView;
/// list play
- (void)updateRotateView:(ZFPlayerView *)rotateView
rotateViewAtCell:(UIView *)cell
playerViewTag:(NSInteger)playerViewTag;
/// 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.
@property (nonatomic, weak) UIView *containerView;

View File

@@ -27,8 +27,6 @@
#import "ZFPortraitViewController.h"
#import "ZFPlayerConst.h"
#import <objc/runtime.h>
#import "ZFLandscapeRotationManager_iOS15.h"
#import "ZFLandscapeRotationManager_iOS16.h"
@interface UIWindow (CurrentViewController)
@@ -42,7 +40,7 @@
@implementation UIWindow (CurrentViewController)
+ (UIViewController*)zf_currentViewController {
+ (UIViewController*)zf_currentViewController; {
__block UIWindow *window;
if (@available(iOS 13, *)) {
[[UIApplication sharedApplication].connectedScenes enumerateObjectsUsingBlock:^(UIScene * _Nonnull scene, BOOL * _Nonnull scenesStop) {
@@ -78,19 +76,32 @@
@end
@interface ZFOrientationObserver ()
@interface ZFOrientationObserver () <ZFLandscapeViewControllerDelegate>
@property (nonatomic, weak) ZFPlayerView *view;
@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.
@property (nonatomic, assign) BOOL activeDeviceObserver;
/// Force Rotaion, default NO.
@property (nonatomic, assign) BOOL forceRotaion;
@end
@implementation ZFOrientationObserver
@@ -101,22 +112,29 @@
if (self) {
_duration = 0.30;
_fullScreenMode = ZFFullScreenModeLandscape;
_supportInterfaceOrientation = ZFInterfaceOrientationMaskAllButUpsideDown;
_allowOrientationRotation = YES;
_rotateType = ZFRotateTypeNormal;
_currentOrientation = UIInterfaceOrientationPortrait;
_portraitFullScreenMode = ZFPortraitFullScreenModeScaleToFill;
_disablePortraitGestureTypes = ZFDisablePortraitGestureTypesAll;
self.supportInterfaceOrientation = ZFInterfaceOrientationMaskAllButUpsideDown;
self.allowOrientationRotation = YES;
self.activeDeviceObserver = YES;
}
return self;
}
- (void)updateRotateView:(ZFPlayerView *)rotateView
containerView:(UIView *)containerView {
self.rotateType = ZFRotateTypeNormal;
self.view = rotateView;
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 {
[self removeDeviceOrientationObserver];
@@ -142,7 +160,49 @@
- (void)handleDeviceOrientationChange {
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
@@ -153,7 +213,47 @@
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion {
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 {
@@ -184,7 +284,7 @@
}
- (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 {
@@ -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
- (ZFPortraitViewController *)portraitViewController {
@@ -222,50 +444,10 @@
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
- (void)setLockedScreen:(BOOL)lockedScreen {
_lockedScreen = lockedScreen;
self.landscapeRotationManager.lockedScreen = lockedScreen;
if (lockedScreen) {
[self removeDeviceOrientationObserver];
} 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 {
_fullScreen = fullScreen;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate];
[self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
[UIViewController attemptRotationToDeviceOrientation];
}
@@ -285,8 +476,8 @@
self.portraitViewController.statusBarHidden = fullScreenStatusBarHidden;
[self.portraitViewController setNeedsStatusBarAppearanceUpdate];
} else if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.landscapeViewController.statusBarHidden = fullScreenStatusBarHidden;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate];
self.window.landscapeViewController.statusBarHidden = fullScreenStatusBarHidden;
[self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
}
}
@@ -296,8 +487,8 @@
self.portraitViewController.statusBarStyle = fullScreenStatusBarStyle;
[self.portraitViewController setNeedsStatusBarAppearanceUpdate];
} else if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.landscapeViewController.statusBarStyle = fullScreenStatusBarStyle;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate];
self.window.landscapeViewController.statusBarStyle = fullScreenStatusBarStyle;
[self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
}
}
@@ -307,8 +498,8 @@
self.portraitViewController.statusBarAnimation = fullScreenStatusBarAnimation;
[self.portraitViewController setNeedsStatusBarAppearanceUpdate];
} else if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.landscapeViewController.statusBarAnimation = fullScreenStatusBarAnimation;
[self.landscapeRotationManager.landscapeViewController setNeedsStatusBarAppearanceUpdate];
self.window.landscapeViewController.statusBarAnimation = fullScreenStatusBarAnimation;
[self.window.landscapeViewController setNeedsStatusBarAppearanceUpdate];
}
}
@@ -325,20 +516,24 @@
}
- (void)setView:(ZFPlayerView *)view {
if (view == _view) { return; }
if (view == _view) {
return;
}
_view = view;
if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.contentView = view;
if (self.fullScreenMode == ZFFullScreenModeLandscape && self.window) {
self.window.landscapeViewController.contentView = view;
} else if (self.fullScreenMode == ZFFullScreenModePortrait) {
self.portraitViewController.contentView = view;
}
}
- (void)setContainerView:(UIView *)containerView {
if (containerView == _containerView) { return; }
if (containerView == _containerView) {
return;
}
_containerView = containerView;
if (self.fullScreenMode == ZFFullScreenModeLandscape) {
self.landscapeRotationManager.containerView = containerView;
self.window.landscapeViewController.containerView = containerView;
} else if (self.fullScreenMode == ZFFullScreenModePortrait) {
self.portraitViewController.containerView = containerView;
}
@@ -346,17 +541,11 @@
- (void)setAllowOrientationRotation:(BOOL)allowOrientationRotation {
_allowOrientationRotation = allowOrientationRotation;
self.landscapeRotationManager.allowOrientationRotation = allowOrientationRotation;
}
- (void)setSupportInterfaceOrientation:(ZFInterfaceOrientationMask)supportInterfaceOrientation {
_supportInterfaceOrientation = supportInterfaceOrientation;
self.landscapeRotationManager.supportInterfaceOrientation = supportInterfaceOrientation;
}
- (void)setActiveDeviceObserver:(BOOL)activeDeviceObserver {
_activeDeviceObserver = activeDeviceObserver;
self.landscapeRotationManager.activeDeviceObserver = activeDeviceObserver;
if (allowOrientationRotation) {
[self addDeviceOrientationObserver];
} else {
[self removeDeviceOrientationObserver];
}
}
@end

View File

@@ -37,28 +37,26 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZFPlayerController : NSObject
/// The video contrainerView in normal model.
@property (nonatomic, weak, nullable) UIView *containerView;
@property (nonatomic, strong) UIView *containerView;
/// The currentPlayerManager must conform `ZFPlayerMediaPlayback` protocol.
@property (nonatomic, strong) id<ZFPlayerMediaPlayback> currentPlayerManager;
/// The custom controlView must conform `ZFPlayerMediaControl` protocol.
@property (nonatomic, strong, nullable) UIView<ZFPlayerMediaControl> *controlView;
@property (nonatomic, strong) UIView<ZFPlayerMediaControl> *controlView;
/// The notification manager class.
@property (nonatomic, strong, readonly, nullable) ZFPlayerNotification *notification;
@property (nonatomic, strong, readonly) ZFPlayerNotification *notification;
/// The container view type.
@property (nonatomic, assign, readonly) ZFPlayerContainerType containerType;
/// 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.
@property (nonatomic, assign, readonly) BOOL isSmallFloatViewShow;
/// The scroll view is `tableView` or `collectionView`.
@property (nonatomic, weak, nullable) UIScrollView *scrollView;
/*!
@method playerWithPlayerManager:containerView:
@abstract Create an ZFPlayerController that plays a single audiovisual item.
@@ -164,7 +162,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) float brightness;
/// 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 more sections , use `sectionAssetURLs`.
@@ -302,6 +300,10 @@ NS_ASSUME_NONNULL_BEGIN
/// Lock the screen orientation.
@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.
@property (nonatomic, copy, nullable) void(^orientationWillChange)(ZFPlayerController *player, BOOL isFullScreen);
@@ -395,6 +397,9 @@ NS_ASSUME_NONNULL_BEGIN
@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.
@property (nonatomic) BOOL shouldAutoPlay;

View File

@@ -35,6 +35,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
@interface ZFPlayerController ()
@property (nonatomic, strong) ZFPlayerNotification *notification;
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic, strong) UISlider *volumeViewSlider;
@property (nonatomic, assign) NSInteger containerViewTag;
@property (nonatomic, assign) ZFPlayerContainerType containerType;
@@ -49,6 +50,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
@implementation ZFPlayerController
@dynamic scrollView;
@dynamic containerViewTag;
@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
@implementation ZFPlayerController (ZFPlayerTimeControl)
@@ -528,7 +425,6 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
[self.currentPlayerManager stop];
[self.currentPlayerManager.view removeFromSuperview];
}
self.lockedScreen = NO;
if (self.scrollView) self.scrollView.zf_stopPlay = YES;
[self.notification removeNotification];
[self.orientationObserver removeDeviceOrientationObserver];
@@ -538,7 +434,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
self.currentPlayerManager = playerManager;
}
/// Add video to the cell
//// Add video to the cell
- (void)addPlayerViewToCell {
self.isSmallFloatViewShow = NO;
self.smallFloatView.hidden = YES;
@@ -547,10 +443,10 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
[self.containerView addSubview:self.currentPlayerManager.view];
self.currentPlayerManager.view.frame = self.containerView.bounds;
self.currentPlayerManager.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.orientationObserver updateRotateView:self.currentPlayerManager.view rotateViewAtCell:cell playerViewTag:self.containerViewTag];
if ([self.controlView respondsToSelector:@selector(videoPlayer:floatViewShow:)]) {
[self.controlView videoPlayer:self floatViewShow:NO];
}
[self layoutPlayerSubViews];
}
//// Add video to the container view
@@ -847,7 +743,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
/// Enter the fullScreen while the ZFFullScreenMode is ZFFullScreenModeLandscape.
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion {
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 {
@@ -920,6 +816,10 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
return YES;
}
- (UIInterfaceOrientation)currentOrientation {
return self.orientationObserver.currentOrientation;
}
- (BOOL)isStatusBarHidden {
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
@@ -1114,6 +1014,111 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
#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 {
objc_setAssociatedObject(self, @selector(isWWANAutoPlay), @(WWANAutoPlay), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
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];
self.containerView = [cell viewWithTag:self.containerViewTag];
[self.orientationObserver updateRotateView:self.currentPlayerManager.view rotateViewAtCell:cell playerViewTag:self.containerViewTag];
[self addDeviceOrientationObserver];
self.scrollView.zf_playingIndexPath = playingIndexPath;
[self layoutPlayerSubViews];
@@ -1200,6 +1206,11 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
#pragma mark - getter
- (UIScrollView *)scrollView {
UIScrollView *scrollView = objc_getAssociatedObject(self, _cmd);
return scrollView;
}
- (BOOL)isWWANAutoPlay {
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
@@ -1361,6 +1372,7 @@ static NSMutableDictionary <NSString* ,NSNumber *> *_zfPlayRecords;
if (self.currentPlayerManager.view && self.playingIndexPath && self.containerViewTag) {
UIView *cell = [self.scrollView zf_getCellForIndexPath:self.playingIndexPath];
self.containerView = [cell viewWithTag:self.containerViewTag];
[self.orientationObserver updateRotateView:self.currentPlayerManager.view rotateViewAtCell:cell playerViewTag:self.containerViewTag];
[self layoutPlayerSubViews];
}
}

View File

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

View File

@@ -37,7 +37,7 @@ static BOOL kLogEnable = NO;
}
+ (NSString *)version {
return @"4.1.2";
return @"4.0.2";
}
+ (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;
/// The play asset URL.
@property (nonatomic, nullable) NSURL *assetURL;
@property (nonatomic) NSURL *assetURL;
/// The video size.
@property (nonatomic) CGSize presentationSize;

View File

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

View File

@@ -33,7 +33,6 @@ typedef NS_ENUM(NSInteger, ZFReachabilityStatus) {
ZFReachabilityStatusReachableVia2G = 2,
ZFReachabilityStatusReachableVia3G = 3,
ZFReachabilityStatusReachableVia4G = 4,
ZFReachabilityStatusReachableVia5G = 5
};
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/ )
@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

View File

@@ -48,8 +48,6 @@ NSString * ZFStringFromNetworkReachabilityStatus(ZFReachabilityStatus status) {
return NSLocalizedStringFromTable(@"Reachable via 3G", @"ZFPlayer", nil);
case ZFReachabilityStatusReachableVia4G:
return NSLocalizedStringFromTable(@"Reachable via 4G", @"ZFPlayer", nil);
case ZFReachabilityStatusReachableVia5G:
return NSLocalizedStringFromTable(@"Reachable via 5G", @"ZFPlayer", nil);
case ZFReachabilityStatusUnknown:
default:
return NSLocalizedStringFromTable(@"Unknown", @"ZFPlayer", nil);
@@ -71,36 +69,13 @@ static ZFReachabilityStatus ZFReachabilityStatusForFlags(SCNetworkReachabilityFl
else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
CTTelephonyNetworkInfo * info = [[CTTelephonyNetworkInfo alloc] init];
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 isEqualToString:CTRadioAccessTechnologyEdge]
|| [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]) {
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
status = ZFReachabilityStatusReachableVia4G;
} else if (@available(iOS 14.1, *)) {
if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]
|| [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
status = ZFReachabilityStatusReachableVia5G;
}
} else if ([currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge] || [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
status = ZFReachabilityStatusReachableVia2G;
} 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);
}
@@ -250,7 +225,7 @@ static void ZFReachabilityReleaseCallback(const void *info) {
};
SCNetworkReachabilityContext context = {0, (__bridge void *)callback, ZFReachabilityRetainCallback, ZFReachabilityReleaseCallback, NULL};
SCNetworkReachabilitySetCallback(self.networkReachability, ZFPlayerReachabilityCallback, &context);
SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
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

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

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