Skip to content

Commit

Permalink
添加 iOS 14 画中画支持
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Sep 26, 2020
1 parent da56513 commit df27419
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion SJBaseVideoPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SJBaseVideoPlayer'
s.version = '3.3.9'
s.version = '3.4.0'
s.summary = 'video player.'
s.description = 'https://github.com/changsanjiang/SJBaseVideoPlayer/blob/master/README.md'
s.homepage = 'https://github.com/changsanjiang/SJBaseVideoPlayer'
Expand Down
10 changes: 7 additions & 3 deletions SJBaseVideoPlayer/Common/Implements/SJRotationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

#import <Foundation/Foundation.h>
#import "SJRotationManagerDefines.h"
#import "SJViewControllerManagerDefines.h"
@protocol SJRotationManagerDelegate;

NS_ASSUME_NONNULL_BEGIN
@interface SJRotationManager : NSObject<SJRotationManager>
@property (nonatomic, weak, nullable) id<SJRotationManagerDelegate> delegate;
@end

@property (nonatomic, weak, nullable) id<SJViewControllerManager> viewControllerManager;

@protocol SJRotationManagerDelegate <NSObject>
- (BOOL)prefersStatusBarHidden;
- (UIStatusBarStyle)preferredStatusBarStyle;
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
@end
NS_ASSUME_NONNULL_END
6 changes: 3 additions & 3 deletions SJBaseVideoPlayer/Common/Implements/SJRotationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ - (CGRect)targetOriginFrame {
}

- (BOOL)prefersStatusBarHidden {
return self.viewControllerManager.prefersStatusBarHidden;
return self.delegate.prefersStatusBarHidden;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
return self.viewControllerManager.preferredStatusBarStyle;
return self.delegate.preferredStatusBarStyle;
}

- (void)vc_forwardPushViewController:(UIViewController *)viewController animated:(BOOL)animated {
[self.viewControllerManager pushViewController:viewController animated:animated];
[self.delegate pushViewController:viewController animated:animated];
}

#pragma mark -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
#import "SJRotationManagerDefines.h"
#import "SJControlLayerAppearManagerDefines.h"
#import "SJVideoPlayerPresentViewDefines.h"
#import "SJRotationManager.h"

NS_ASSUME_NONNULL_BEGIN
@interface SJViewControllerManager : NSObject<SJViewControllerManager>
@interface SJViewControllerManager : NSObject<SJViewControllerManager, SJRotationManagerDelegate>
@property (nonatomic, weak, nullable) id<SJFitOnScreenManager> fitOnScreenManager;
@property (nonatomic, weak, nullable) id<SJRotationManager> rotationManager;
@property (nonatomic, weak, nullable) id<SJControlLayerAppearManager> controlLayerAppearManager;
Expand Down
41 changes: 23 additions & 18 deletions SJBaseVideoPlayer/SJBaseVideoPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ @interface SJBaseVideoPlayer ()<SJVideoPlayerPresentViewDelegate, SJPlayerViewDe

/// - observe视图的滚动
@property (nonatomic, strong, nullable) SJPlayModelPropertiesObserver *playModelObserver;
@property (nonatomic, strong, readonly) SJViewControllerManager *viewControllerManager;
@property (nonatomic, strong) SJViewControllerManager *viewControllerManager;
@end

@implementation SJBaseVideoPlayer {
Expand Down Expand Up @@ -157,7 +157,7 @@ + (instancetype)player {
}

+ (NSString *)version {
return @"v3.3.6";
return @"v3.4.0";
}

- (void)setVideoGravity:(SJVideoGravity)videoGravity {
Expand Down Expand Up @@ -200,13 +200,16 @@ - (instancetype)init {
self.autoManageViewToFitOnScreenOrRotation = YES;

[self _setupViews];
[self _showOrHiddenPlaceholderImageViewIfNeeded];
[self fitOnScreenManager];
[self rotationManager];
[self controlLayerAppearManager];
[self registrar];
[self reachability];
[self gestureControl];
[self.deviceVolumeAndBrightnessManager prepare];
[self performSelectorInBackground:@selector(_configAVAudioSession) withObject:nil];
[self _setupViewControllerManager];
[self _showOrHiddenPlaceholderImageViewIfNeeded];
return self;
}

Expand Down Expand Up @@ -435,19 +438,6 @@ - (void)setControlLayerDataSource:(nullable id<SJVideoPlayerControlLayerDataSour

#pragma mark -

@synthesize viewControllerManager = _viewControllerManager;
- (SJViewControllerManager *)viewControllerManager {
if ( _viewControllerManager == nil ) {
_viewControllerManager = SJViewControllerManager.alloc.init;
_viewControllerManager.fitOnScreenManager = self.fitOnScreenManager;
_viewControllerManager.rotationManager = self.rotationManager;
_viewControllerManager.controlLayerAppearManager = self.controlLayerAppearManager;
_viewControllerManager.presentView = self.presentView;
_viewControllerManager.lockedScreen = self.isLockedScreen;
}
return _viewControllerManager;
}

- (SJVideoPlayerRegistrar *)registrar {
if ( _registrar ) return _registrar;
_registrar = [SJVideoPlayerRegistrar new];
Expand Down Expand Up @@ -518,6 +508,22 @@ - (void)_setupViews {
[_view addSubview:_presentView];
}

- (void)_setupViewControllerManager {
if ( _viewControllerManager == nil ) {
_viewControllerManager = SJViewControllerManager.alloc.init;
}
_viewControllerManager.fitOnScreenManager = _fitOnScreenManager;
_viewControllerManager.rotationManager = _rotationManager;
_viewControllerManager.controlLayerAppearManager = _controlLayerAppearManager;
_viewControllerManager.presentView = self.presentView;
_viewControllerManager.lockedScreen = self.isLockedScreen;

if ( [_rotationManager isKindOfClass:SJRotationManager.class] ) {
SJRotationManager *mgr = _rotationManager;
mgr.delegate = _viewControllerManager;
}
}

- (void)_configAVAudioSession {
if ( AVAudioSession.sharedInstance.category != AVAudioSessionCategoryPlayback &&
AVAudioSession.sharedInstance.category != AVAudioSessionCategoryPlayAndRecord ) {
Expand Down Expand Up @@ -1610,7 +1616,6 @@ - (void)setFitOnScreenManager:(id<SJFitOnScreenManager> _Nullable)fitOnScreenMan
- (id<SJFitOnScreenManager>)fitOnScreenManager {
if ( _fitOnScreenManager == nil ) {
SJFitOnScreenManager *mgr = [[SJFitOnScreenManager alloc] initWithTarget:self.presentView targetSuperview:self.view];
mgr.viewControllerManager = self.viewControllerManager;
[self setFitOnScreenManager:mgr];
}
return _fitOnScreenManager;
Expand Down Expand Up @@ -1696,7 +1701,7 @@ - (void)setRotationManager:(nullable id<SJRotationManager>)rotationManager {
- (id<SJRotationManager>)rotationManager {
if ( _rotationManager == nil ) {
SJRotationManager *mgr = [SJRotationManager.alloc init];
mgr.viewControllerManager = self.viewControllerManager;
mgr.delegate = _viewControllerManager;
[self setRotationManager:mgr];
}
return _rotationManager;
Expand Down

0 comments on commit df27419

Please sign in to comment.