diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m index a35422920..3ddf738e5 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m @@ -102,12 +102,16 @@ @implementation SJFloatSmallViewController @synthesize enabled = _enabled; @synthesize target = _target; @synthesize safeMargin = _safeMargin; +@synthesize floatViewInsets = _floatViewInsets; +@synthesize floatViewAlignment = _floatViewAlignment; @synthesize addFloatViewToKeyWindow = _addFloatViewToKeyWindow; - (instancetype)init { self = [super init]; if ( self ) { _safeMargin = 12; + _floatViewInsets = UIEdgeInsetsZero; + _floatViewAlignment = SJFloatViewAlignmentBottomRight; } return self; } @@ -142,13 +146,49 @@ - (void)showFloatView { [superview addSubview:_floatView]; CGRect bounds = superview.bounds; CGFloat width = bounds.size.width; - + CGFloat height = bounds.size.height; // CGFloat maxW = ceil(width * 0.48); CGFloat w = maxW>300?300:maxW; CGFloat h = w * 9 /16.0; - CGFloat x = width - w - _safeMargin; - CGFloat y = _safeMargin; + CGFloat x = 0; + CGFloat y = 0; + + switch (_floatViewAlignment) { + case SJFloatViewAlignmentTop: + x = (width - w)/2; + y = _floatViewInsets.top; + break; + case SJFloatViewAlignmentTopLeft: + x = _floatViewInsets.left; + y = _floatViewInsets.top; + break; + case SJFloatViewAlignmentLeft: + x = _floatViewInsets.left; + y = (height - h)/2; + break; + case SJFloatViewAlignmentBottomLeft: + x = _floatViewInsets.left; + y = height - h - _floatViewInsets.bottom; + break; + case SJFloatViewAlignmentBottom: + x = (width - w)/2; + y = height - h - _floatViewInsets.bottom; + break; + case SJFloatViewAlignmentBottomRight: + x = width - w - _floatViewInsets.right; + y = height - h - _floatViewInsets.bottom; + break; + case SJFloatViewAlignmentRight: + x = width - w - _floatViewInsets.right; + y = (height - h)/2; + break; + case SJFloatViewAlignmentTopRight: + x = width - w - _floatViewInsets.right; + y = _floatViewInsets.top; + break; + } + if (@available(iOS 11.0, *)) { y += superview.safeAreaInsets.top; } diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h index 323c036e7..ec5ff74de 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h @@ -11,6 +11,18 @@ #import NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, SJFloatViewAlignment) { + SJFloatViewAlignmentTop = 0, + SJFloatViewAlignmentTopLeft = 1, + SJFloatViewAlignmentTopRight = 2, + SJFloatViewAlignmentLeft = 3, + SJFloatViewAlignmentBottomLeft = 4, + SJFloatViewAlignmentBottom = 5, + SJFloatViewAlignmentBottomRight = 6, + SJFloatViewAlignmentRight = 7 +}; + @protocol SJFloatSmallViewController - (id)getObserver; @@ -61,6 +73,10 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) CGFloat safeMargin; ///< default value is 12. +@property (nonatomic) UIEdgeInsets floatViewInsets; /// + +@property (nonatomic) SJFloatViewAlignment floatViewAlignment; /// default value is SJFloatViewAlignmentBottomRight + /// 以下属性由播放器维护 /// /// - target 为播放器呈现视图 diff --git a/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m b/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m index 1402dbe51..e621d7f28 100644 --- a/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m +++ b/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m @@ -30,6 +30,9 @@ - (void)coverItemWasTapped:(SJVideoTableViewCell *)cell { _player = [SJVideoPlayer player]; // 开启小浮窗(当播放器视图滑动消失时, 显示小浮窗视图) _player.floatSmallViewController.enabled = YES; + // 自定义浮窗的初始位置 + _player.floatSmallViewController.floatViewAlignment = SJFloatViewAlignmentBottomRight; + _player.floatSmallViewController.floatViewInsets = UIEdgeInsetsMake(0, 0, 20, 12); __weak typeof(self) _self = self; // 单击小浮窗时的回调