diff --git a/Example/.DS_Store b/Example/.DS_Store index 7e3dc6ac0..bcf398864 100644 Binary files a/Example/.DS_Store and b/Example/.DS_Store differ diff --git a/Example/Podfile b/Example/Podfile index 878e6d16f..ce609def5 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -46,7 +46,7 @@ target 'SJVideoPlayer_Example' do # pod 'SJBaseVideoPlayer/IJKPlayer', :path => '../../SJBaseVideoPlayer' # ## 切换为 Aliplayer, 详见: https://github.com/changsanjiang/SJVideoPlayer/wiki/Use-AliPlayer -# pod 'SJBaseVideoPlayer/AliPlayer', :path => '../../SJBaseVideoPlayer' +# pod 'SJBaseVideoPlayer/AliPlayer'#, :path => '../../SJBaseVideoPlayer' # ## 切换为 AliVodPlayer, 详见: https://github.com/changsanjiang/SJVideoPlayer/wiki/Use-AliVodPlayer # pod 'SJBaseVideoPlayer/AliVodPlayer', :path => '../../SJBaseVideoPlayer' diff --git a/Example/Podfile.lock b/Example/Podfile.lock index eca1379f1..b4f44ecfa 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -7,40 +7,40 @@ PODS: - SDWebImage (5.9.5): - SDWebImage/Core (= 5.9.5) - SDWebImage/Core (5.9.5) - - SJBaseVideoPlayer (3.4.3): + - SJBaseVideoPlayer (3.4.5): - Masonry - - SJBaseVideoPlayer/AVPlayer (= 3.4.3) - - SJBaseVideoPlayer/Common (= 3.4.3) + - SJBaseVideoPlayer/AVPlayer (= 3.4.5) + - SJBaseVideoPlayer/Common (= 3.4.5) - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/AVPlayer (3.4.3): + - SJBaseVideoPlayer/AVPlayer (3.4.5): - Masonry - SJBaseVideoPlayer/Common - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/Common (3.4.3): + - SJBaseVideoPlayer/Common (3.4.5): - Masonry - SJBaseVideoPlayer/ResourceLoader - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/ResourceLoader (3.4.3): + - SJBaseVideoPlayer/ResourceLoader (3.4.5): - Masonry - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - SJFullscreenPopGesture/ObjC (1.5.4) - - SJMediaCacheServer (1.3.0): + - SJMediaCacheServer (1.3.2): - KTVCocoaHTTPServer - - SJMediaCacheServer/Core (= 1.3.0) + - SJMediaCacheServer/Core (= 1.3.2) - SJUIKit/SQLite3 - - SJMediaCacheServer/Core (1.3.0): + - SJMediaCacheServer/Core (1.3.2): - KTVCocoaHTTPServer - SJUIKit/SQLite3 - SJPlaybackListController (0.0.5): @@ -108,21 +108,21 @@ PODS: - SJUIKit/UIMaker (0.0.0.51): - SJUIKit/UIMaker/Core (= 0.0.0.51) - SJUIKit/UIMaker/Core (0.0.0.51) - - SJVideoPlayer (3.2.8): - - SJBaseVideoPlayer (>= 3.4.3) - - SJVideoPlayer/Common (= 3.2.8) - - SJVideoPlayer/ControlLayers (= 3.2.8) - - SJVideoPlayer/ResourceLoader (= 3.2.8) - - SJVideoPlayer/Common (3.2.8): + - SJVideoPlayer (3.2.9): + - SJBaseVideoPlayer (>= 3.4.5) + - SJVideoPlayer/Common (= 3.2.9) + - SJVideoPlayer/ControlLayers (= 3.2.9) + - SJVideoPlayer/ResourceLoader (= 3.2.9) + - SJVideoPlayer/Common (3.2.9): - Masonry - - SJBaseVideoPlayer (>= 3.4.3) + - SJBaseVideoPlayer (>= 3.4.5) - SJUIKit/AttributesFactory - SJVideoPlayer/ResourceLoader - - SJVideoPlayer/ControlLayers (3.2.8): - - SJBaseVideoPlayer (>= 3.4.3) + - SJVideoPlayer/ControlLayers (3.2.9): + - SJBaseVideoPlayer (>= 3.4.5) - SJVideoPlayer/Common - - SJVideoPlayer/ResourceLoader (3.2.8): - - SJBaseVideoPlayer (>= 3.4.3) + - SJVideoPlayer/ResourceLoader (3.2.9): + - SJBaseVideoPlayer (>= 3.4.5) - YYModel (1.0.4) DEPENDENCIES: @@ -163,15 +163,15 @@ SPEC CHECKSUMS: Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 MJRefresh: 53e3e3219f204425ee6d3e62e8733d3295944cd6 SDWebImage: 0b2ba0d56479bf6a45ecddbfd5558bea93150d25 - SJBaseVideoPlayer: 7af90105490cc751c2ddbfa615c943f88b256216 + SJBaseVideoPlayer: 0ecccbae3bf6cad55187113247ea88f711bef276 SJFullscreenPopGesture: 7be57b1014cb77f4b7c1e6df5e797da6d05dc75d - SJMediaCacheServer: 3badbaedb7794c10226b2ab97a1f81bc71105ffb + SJMediaCacheServer: 4e9203033c21d742b6030e7704aeb61dc38840cd SJPlaybackListController: e135c789fcd63d63a62d5e2e2965ab1e6d52a2bd SJRouter: a866e7884fc9219bed523be0a0318c3a84e85022 SJUIKit: bdf86af3648e70483c57e2bfe2fcc7531337fa54 - SJVideoPlayer: 0cbef06cd6c762c4d672a664a87164ed430972dd + SJVideoPlayer: 3cccc263bc03edccedc1b2be887b903e3dfca106 YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30 -PODFILE CHECKSUM: 6267c2a571b00c2bc5ea1b3ffccbc66b168e68be +PODFILE CHECKSUM: 29e274b3a7b747f79a95901fcf2d39e60d7aef9d COCOAPODS: 1.10.0 diff --git a/Example/Pods/Local Podspecs/SJVideoPlayer.podspec.json b/Example/Pods/Local Podspecs/SJVideoPlayer.podspec.json index ee5f634af..009d8e620 100644 --- a/Example/Pods/Local Podspecs/SJVideoPlayer.podspec.json +++ b/Example/Pods/Local Podspecs/SJVideoPlayer.podspec.json @@ -1,6 +1,6 @@ { "name": "SJVideoPlayer", - "version": "3.2.8", + "version": "3.2.9", "summary": "video player.", "description": "https://github.com/changsanjiang/SJVideoPlayer/blob/master/README.md", "homepage": "https://github.com/changsanjiang/SJVideoPlayer", @@ -16,12 +16,12 @@ }, "source": { "git": "https://github.com/changsanjiang/SJVideoPlayer.git", - "tag": "v3.2.8" + "tag": "v3.2.9" }, "requires_arc": true, "dependencies": { "SJBaseVideoPlayer": [ - ">= 3.4.3" + ">= 3.4.5" ] }, "source_files": "SJVideoPlayer/*.{h,m}", diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index eca1379f1..b4f44ecfa 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -7,40 +7,40 @@ PODS: - SDWebImage (5.9.5): - SDWebImage/Core (= 5.9.5) - SDWebImage/Core (5.9.5) - - SJBaseVideoPlayer (3.4.3): + - SJBaseVideoPlayer (3.4.5): - Masonry - - SJBaseVideoPlayer/AVPlayer (= 3.4.3) - - SJBaseVideoPlayer/Common (= 3.4.3) + - SJBaseVideoPlayer/AVPlayer (= 3.4.5) + - SJBaseVideoPlayer/Common (= 3.4.5) - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/AVPlayer (3.4.3): + - SJBaseVideoPlayer/AVPlayer (3.4.5): - Masonry - SJBaseVideoPlayer/Common - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/Common (3.4.3): + - SJBaseVideoPlayer/Common (3.4.5): - Masonry - SJBaseVideoPlayer/ResourceLoader - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/ResourceLoader (3.4.3): + - SJBaseVideoPlayer/ResourceLoader (3.4.5): - Masonry - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - SJFullscreenPopGesture/ObjC (1.5.4) - - SJMediaCacheServer (1.3.0): + - SJMediaCacheServer (1.3.2): - KTVCocoaHTTPServer - - SJMediaCacheServer/Core (= 1.3.0) + - SJMediaCacheServer/Core (= 1.3.2) - SJUIKit/SQLite3 - - SJMediaCacheServer/Core (1.3.0): + - SJMediaCacheServer/Core (1.3.2): - KTVCocoaHTTPServer - SJUIKit/SQLite3 - SJPlaybackListController (0.0.5): @@ -108,21 +108,21 @@ PODS: - SJUIKit/UIMaker (0.0.0.51): - SJUIKit/UIMaker/Core (= 0.0.0.51) - SJUIKit/UIMaker/Core (0.0.0.51) - - SJVideoPlayer (3.2.8): - - SJBaseVideoPlayer (>= 3.4.3) - - SJVideoPlayer/Common (= 3.2.8) - - SJVideoPlayer/ControlLayers (= 3.2.8) - - SJVideoPlayer/ResourceLoader (= 3.2.8) - - SJVideoPlayer/Common (3.2.8): + - SJVideoPlayer (3.2.9): + - SJBaseVideoPlayer (>= 3.4.5) + - SJVideoPlayer/Common (= 3.2.9) + - SJVideoPlayer/ControlLayers (= 3.2.9) + - SJVideoPlayer/ResourceLoader (= 3.2.9) + - SJVideoPlayer/Common (3.2.9): - Masonry - - SJBaseVideoPlayer (>= 3.4.3) + - SJBaseVideoPlayer (>= 3.4.5) - SJUIKit/AttributesFactory - SJVideoPlayer/ResourceLoader - - SJVideoPlayer/ControlLayers (3.2.8): - - SJBaseVideoPlayer (>= 3.4.3) + - SJVideoPlayer/ControlLayers (3.2.9): + - SJBaseVideoPlayer (>= 3.4.5) - SJVideoPlayer/Common - - SJVideoPlayer/ResourceLoader (3.2.8): - - SJBaseVideoPlayer (>= 3.4.3) + - SJVideoPlayer/ResourceLoader (3.2.9): + - SJBaseVideoPlayer (>= 3.4.5) - YYModel (1.0.4) DEPENDENCIES: @@ -163,15 +163,15 @@ SPEC CHECKSUMS: Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 MJRefresh: 53e3e3219f204425ee6d3e62e8733d3295944cd6 SDWebImage: 0b2ba0d56479bf6a45ecddbfd5558bea93150d25 - SJBaseVideoPlayer: 7af90105490cc751c2ddbfa615c943f88b256216 + SJBaseVideoPlayer: 0ecccbae3bf6cad55187113247ea88f711bef276 SJFullscreenPopGesture: 7be57b1014cb77f4b7c1e6df5e797da6d05dc75d - SJMediaCacheServer: 3badbaedb7794c10226b2ab97a1f81bc71105ffb + SJMediaCacheServer: 4e9203033c21d742b6030e7704aeb61dc38840cd SJPlaybackListController: e135c789fcd63d63a62d5e2e2965ab1e6d52a2bd SJRouter: a866e7884fc9219bed523be0a0318c3a84e85022 SJUIKit: bdf86af3648e70483c57e2bfe2fcc7531337fa54 - SJVideoPlayer: 0cbef06cd6c762c4d672a664a87164ed430972dd + SJVideoPlayer: 3cccc263bc03edccedc1b2be887b903e3dfca106 YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30 -PODFILE CHECKSUM: 6267c2a571b00c2bc5ea1b3ffccbc66b168e68be +PODFILE CHECKSUM: 29e274b3a7b747f79a95901fcf2d39e60d7aef9d COCOAPODS: 1.10.0 diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayer.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayer.m index 9fc97d097..e398ae519 100644 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayer.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayer.m @@ -548,15 +548,6 @@ - (void)_didPlayToTrialEndPosition { } } -- (void)_didPlayToEndPositoion { - if ( self.finishedReason != SJFinishedReasonToEndTimePosition ) { - self.finishedReason = SJFinishedReasonToEndTimePosition; - self.isPlaybackFinished = YES; - self.reasonForWaitingToPlay = nil; - self.timeControlStatus = SJPlaybackTimeControlStatusPaused; - } -} - - (CMTime)_adjustSeekTimeIfNeeded:(CMTime)time { if ( _trialEndPosition != 0 && CMTimeGetSeconds(time) >= _trialEndPosition ) { time = CMTimeMakeWithSeconds(_trialEndPosition * 0.98, NSEC_PER_SEC); diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.h b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.h index ed32c3d5c..34b61f69c 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.h +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.h @@ -9,7 +9,19 @@ #import "SJFloatSmallViewControllerDefines.h" NS_ASSUME_NONNULL_BEGIN -@interface SJFloatSmallViewController : NSObject +typedef NS_ENUM(NSInteger, SJFloatViewLayoutPosition) { + SJFloatViewLayoutPositionTopLeft, + SJFloatViewLayoutPositionTopRight, + SJFloatViewLayoutPositionBottomLeft, + SJFloatViewLayoutPositionBottomRight, +}; +@interface SJFloatSmallViewController : NSObject +/// default value is SJFloatViewLayoutPositionBottomRight. +@property (nonatomic) SJFloatViewLayoutPosition layoutPosition; +/// default value is UIEdgeInsetsMake(20, 12, 20, 12). +@property (nonatomic) UIEdgeInsets layoutInsets; +@property (nonatomic) CGSize layoutSize; +@property (nonatomic) BOOL ignoreSafeAreaInsets API_AVAILABLE(ios(11.0)); @end NS_ASSUME_NONNULL_END diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m index 3ddf738e5..b2841fc14 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJFloatSmallViewController.m @@ -101,17 +101,16 @@ @implementation SJFloatSmallViewController @synthesize targetSuperview = _targetSuperview; @synthesize enabled = _enabled; @synthesize target = _target; -@synthesize safeMargin = _safeMargin; -@synthesize floatViewInsets = _floatViewInsets; -@synthesize floatViewAlignment = _floatViewAlignment; +@synthesize layoutInsets = _layoutInsets; +@synthesize layoutPosition = _layoutPosition; @synthesize addFloatViewToKeyWindow = _addFloatViewToKeyWindow; +@synthesize layoutSize = _layoutSize; - (instancetype)init { self = [super init]; if ( self ) { - _safeMargin = 12; - _floatViewInsets = UIEdgeInsetsZero; - _floatViewAlignment = SJFloatViewAlignmentBottomRight; + _layoutInsets = UIEdgeInsetsMake(20, 12, 20, 12); + _layoutPosition = SJFloatViewLayoutPositionBottomRight; } return self; } @@ -142,57 +141,53 @@ - (void)showFloatView { else { superview = UIApplication.sharedApplication.keyWindow; } + if ( self.floatView.superview != superview ) { [superview addSubview:_floatView]; - CGRect bounds = superview.bounds; - CGFloat width = bounds.size.width; - CGFloat height = bounds.size.height; + CGRect superViewBounds = superview.bounds; + CGFloat superViewWidth = superViewBounds.size.width; + CGFloat superViewHeight = superViewBounds.size.height; + + UIEdgeInsets safeAreaInsets = UIEdgeInsetsZero; + if (@available(iOS 11.0, *)) { + if ( !_ignoreSafeAreaInsets ) safeAreaInsets = superview.safeAreaInsets; + } + // - CGFloat maxW = ceil(width * 0.48); - CGFloat w = maxW>300?300:maxW; - CGFloat h = w * 9 /16.0; + CGSize size = _layoutSize; + CGFloat w = size.width; + CGFloat h = size.height; 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; + if ( CGSizeEqualToSize(CGSizeZero, size) ) { + CGFloat maxW = ceil(superViewWidth * 0.48); + w = maxW > 300.0 ? 300.0 : maxW; + h = w * 9.0 / 16.0; + } + + switch ( _layoutPosition ) { + case SJFloatViewLayoutPositionTopLeft: + case SJFloatViewLayoutPositionBottomLeft: + x = safeAreaInsets.left + _layoutInsets.left; break; - case SJFloatViewAlignmentBottomRight: - x = width - w - _floatViewInsets.right; - y = height - h - _floatViewInsets.bottom; + case SJFloatViewLayoutPositionTopRight: + case SJFloatViewLayoutPositionBottomRight: + x = superViewWidth - w - _layoutInsets.right - safeAreaInsets.right; break; - case SJFloatViewAlignmentRight: - x = width - w - _floatViewInsets.right; - y = (height - h)/2; + } + + switch ( _layoutPosition ) { + case SJFloatViewLayoutPositionTopLeft: + case SJFloatViewLayoutPositionTopRight: + y = safeAreaInsets.top + _layoutInsets.top; break; - case SJFloatViewAlignmentTopRight: - x = width - w - _floatViewInsets.right; - y = _floatViewInsets.top; + case SJFloatViewLayoutPositionBottomLeft: + case SJFloatViewLayoutPositionBottomRight: + y = superViewHeight - h - _layoutInsets.bottom - safeAreaInsets.bottom; break; } - - if (@available(iOS 11.0, *)) { - y += superview.safeAreaInsets.top; - } - + _floatView.frame = CGRectMake(x, y, w, h); } @@ -269,10 +264,14 @@ - (void)_handlePanGesture:(UIPanGestureRecognizer *)panGesture { case UIGestureRecognizerStateEnded: case UIGestureRecognizerStateCancelled: case UIGestureRecognizerStateFailed: { - CGFloat safeMargin = _safeMargin; [UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ - CGFloat left = safeMargin; - CGFloat right = UIScreen.mainScreen.bounds.size.width - safeMargin - view.w; + UIEdgeInsets safeAreaInsets = UIEdgeInsetsZero; + if (@available(iOS 11.0, *)) { + if ( !self.ignoreSafeAreaInsets ) safeAreaInsets = superview.safeAreaInsets; + } + + CGFloat left = safeAreaInsets.left + self.layoutInsets.left; + CGFloat right = superview.bounds.size.width - view.w - self.layoutInsets.right - safeAreaInsets.right; if ( view.x <= left ) { [view setX:left]; } @@ -280,12 +279,8 @@ - (void)_handlePanGesture:(UIPanGestureRecognizer *)panGesture { [view setX:right]; } - UIEdgeInsets insets = UIEdgeInsetsZero; - if (@available(iOS 11.0, *)) { - insets = superview.safeAreaInsets; - } - CGFloat top = insets.top + safeMargin; - CGFloat bottom = superview.bounds.size.height - (insets.bottom + safeMargin + view.h); + CGFloat top = safeAreaInsets.top + self.layoutInsets.top; + CGFloat bottom = superview.bounds.size.height - view.h - self.layoutInsets.bottom - safeAreaInsets.bottom; if ( view.y <= top ) { [view setY:top]; } diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJPlayModelPropertiesObserver.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJPlayModelPropertiesObserver.m index 5041dc59c..5d13018c8 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJPlayModelPropertiesObserver.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJPlayModelPropertiesObserver.m @@ -66,6 +66,7 @@ - (void)_observeProperties { [_playModel isKindOfClass:SJTableViewTableFooterViewPlayModel.class] ) { SJPlayModel *curr = _playModel; + _beforeOffset = curr.inScrollView.contentOffset; while ( curr != nil ) { [self _observeScrollView:curr.inScrollView]; curr = curr.nextPlayModel; diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJRotationManager.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJRotationManager.m index 604b7c34d..fea3be553 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJRotationManager.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJRotationManager.m @@ -58,9 +58,9 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } -- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { - return UIInterfaceOrientationPortrait; -} +//- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { +// return UIInterfaceOrientationPortrait; +//} - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { _rotating = YES; diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h index ec5ff74de..f63443000 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Interfaces/SJFloatSmallViewControllerDefines.h @@ -11,18 +11,6 @@ #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; @@ -70,13 +58,7 @@ typedef NS_ENUM(NSInteger, SJFloatViewAlignment) { @property (nonatomic) BOOL addFloatViewToKeyWindow; @property (nonatomic, strong, readonly) __kindof UIView *floatView; ///< float view - -@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/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.h b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.h index 86e76e7ce..a5198fff9 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.h +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.h @@ -715,6 +715,13 @@ NS_ASSUME_NONNULL_BEGIN /// // 3. 设置双击小浮窗执行的block /// _player.floatSmallViewController.doubleTappedOnTheFloatViewExeBlock = ...; /// +/// // more +/// #import +/// +/// SJFloatSmallViewController *floatSmallViewController = _player.floatSmallViewController; +/// floatSmallViewController.layoutPosition = SJFloatViewLayoutPositionTopRight; +/// floatSmallViewController.layoutInsets = UIEdgeInsetsMake(20, 12, 20, 12); +/// floatSmallViewController.layoutSize = CGSize(300, 300 * 9 / 16.0); /// \endcode /// @property (nonatomic, strong, null_resettable) id floatSmallViewController; diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m index 6addf535e..7978429d2 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m @@ -47,6 +47,10 @@ NSTimeInterval offsetTime; ///< pan手势触发过程中的偏移量(secs) } pan; + struct { + CGFloat initialRate; + } longPress; + struct { SJPlayerGestureTypeMask disabledGestures; CGFloat rateWhenLongPressGestureTriggered; @@ -401,11 +405,12 @@ - (void)_handlePinch:(CGFloat)scale { - (void)_handleLongPress:(SJLongPressGestureRecognizerState)state { switch ( state ) { case SJLongPressGestureRecognizerStateBegan: + self.controlInfo->longPress.initialRate = self.rate; case SJLongPressGestureRecognizerStateChanged: self.rate = self.rateWhenLongPressGestureTriggered; break; case SJLongPressGestureRecognizerStateEnded: - self.rate = 1.0; + self.rate = self.controlInfo->longPress.initialRate; break; } diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.h b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.h index f6cda9b49..5322b9319 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.h +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.h @@ -19,6 +19,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) BOOL sj_enabledAutoplay; +/// +/// 指定位置播放 +/// +- (void)sj_playAssetAtIndexPath:(NSIndexPath *)indexPath scrollAnimated:(BOOL)animated; + /// /// enable autoplay /// 开启 @@ -44,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN /// Developers don't need to care, this category is automatically maintained by the SJBaseVideoPlayer. /// 开发者无需关心, 此分类由播放器自动维护 -@interface UIScrollView (SJPlayerCurrentPlayingIndexPath) +@interface UIScrollView (SJAutoplayPrivate) @property (nonatomic, strong, nullable, readonly) NSIndexPath *sj_currentPlayingIndexPath; - (void)setSj_currentPlayingIndexPath:(nullable NSIndexPath *)sj_currentPlayingIndexPath; @end diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.m index 6463727d7..73edff1e0 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/UIScrollView+ListViewAutoplaySJAdd.m @@ -26,8 +26,19 @@ NS_ASSUME_NONNULL_BEGIN static NSString *const kQueue = @"SJBaseVideoPlayerAutoplayTaskQueue"; +static void sj_exeAnima(__kindof UIScrollView *scrollView, NSIndexPath *indexPath, SJAutoplayScrollAnimationType animationType); +static void sj_playAsset(UIScrollView *scrollView, NSIndexPath *indexPath, BOOL animated); +static SJRunLoopTaskQueue * +sj_queue(void) { + static SJRunLoopTaskQueue *queue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + queue = SJRunLoopTaskQueue.queue(kQueue).update(CFRunLoopGetMain(), kCFRunLoopDefaultMode); + }); + return queue; +} -@implementation UIScrollView (SJPlayerCurrentPlayingIndexPath) +@implementation UIScrollView (SJAutoplayPrivate) - (void)setSj_currentPlayingIndexPath:(nullable NSIndexPath *)sj_currentPlayingIndexPath { objc_setAssociatedObject(self, @selector(sj_currentPlayingIndexPath), sj_currentPlayingIndexPath, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } @@ -51,6 +62,55 @@ - (BOOL)sj_enabledAutoplay { return [objc_getAssociatedObject(self, _cmd) boolValue]; } +- (void)sj_playAssetAtIndexPath:(NSIndexPath *)indexPath scrollAnimated:(BOOL)animated { + if ( self.window == nil ) + return; + + [self sj_removeCurrentPlayerView]; + + sj_queue().empty(); + if ( [self isKindOfClass:UITableView.class] ) { + UITableView *tableView = (id)self; + UITableViewScrollPosition position = [self sj_autoplayConfig].animationType != SJAutoplayScrollAnimationTypeTop ? UITableViewScrollPositionMiddle : UITableViewScrollPositionTop; + if (@available(iOS 11.0, *)) { + [tableView performBatchUpdates:^{ + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + } completion:^(BOOL finished) { + if ( [tableView numberOfRowsInSection:indexPath.section] > indexPath.row ) { + [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:position animated:animated]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + sj_queue().empty(); + [[self sj_autoplayConfig].autoplayDelegate sj_playerNeedPlayNewAssetAtIndexPath:indexPath]; + }); + } + }]; + } else { + [UIView animateWithDuration:animated ? 0.2 : 0 animations:^{ + [tableView beginUpdates]; + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + [tableView endUpdates]; + } completion:^(BOOL finished) { + if ( [tableView numberOfRowsInSection:indexPath.section] > indexPath.row ) { + [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:position animated:animated]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + sj_queue().empty(); + [[self sj_autoplayConfig].autoplayDelegate sj_playerNeedPlayNewAssetAtIndexPath:indexPath]; + }); + } + }]; + } + } + else if ( [self isKindOfClass:UICollectionView.class] ) { + UICollectionView *collectionView = (id)self; + UICollectionViewScrollPosition position = [self sj_autoplayConfig].animationType != SJAutoplayScrollAnimationTypeTop ? UICollectionViewScrollPositionCenteredVertically : UICollectionViewScrollPositionTop; + [collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:position animated:animated]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + sj_queue().empty(); + [[self sj_autoplayConfig].autoplayDelegate sj_playerNeedPlayNewAssetAtIndexPath:indexPath]; + }); + } +} + - (void)setSj_autoplayConfig:(nullable SJPlayerAutoplayConfig *)sj_autoplayConfig { objc_setAssociatedObject(self, @selector(sj_autoplayConfig), sj_autoplayConfig, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } @@ -62,7 +122,6 @@ - (void)sj_enableAutoplayWithConfig:(SJPlayerAutoplayConfig *)autoplayConfig { self.sj_enabledAutoplay = YES; self.sj_autoplayConfig = autoplayConfig; - SJRunLoopTaskQueue *queue = SJRunLoopTaskQueue.queue(kQueue).update(CFRunLoopGetMain(), kCFRunLoopDefaultMode); __weak typeof(self) _self = self; sj_scrollViewContentOffsetDidChange(self, ^{ __strong typeof(_self) self = _self; @@ -72,7 +131,7 @@ - (void)sj_enableAutoplayWithConfig:(SJPlayerAutoplayConfig *)autoplayConfig { [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(sj_playNextAssetAfterEndScroll) object:nil]; } - queue.empty(); + sj_queue().empty(); /// /// Thanks @YangYus /// @@ -82,7 +141,7 @@ - (void)sj_enableAutoplayWithConfig:(SJPlayerAutoplayConfig *)autoplayConfig { return; } - queue.enqueue(^{ + sj_queue().enqueue(^{ self.sj_hasDelayedEndScrollTask = YES; [self performSelector:@selector(sj_playNextAssetAfterEndScroll) withObject:nil afterDelay:0.4]; }); @@ -171,8 +230,6 @@ static void sj_removeContentOffsetObserver(UIScrollView *scrollView) { } #pragma mark - -static void sj_playAsset(UIScrollView *scrollView, NSIndexPath *indexPath, BOOL animated); -static void sj_exeAnima(__kindof UIScrollView *scrollView, NSIndexPath *indexPath, SJAutoplayScrollAnimationType animationType); static void sj_playNextAssetAfterEndScroll(__kindof __kindof UIScrollView *scrollView) { NSArray *_Nullable visibleIndexPaths = [scrollView sj_visibleIndexPaths]; diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.h b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.h index 7d999b6ae..c8da72ced 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.h +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface FILEReader : NSObject -- (instancetype)initWithAsset:(__weak FILEAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate; +- (instancetype)initWithAsset:(__weak FILEAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^_Nullable)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate; - (void)prepare; @property (nonatomic, copy, readonly, nullable) NSData *(^readDataDecoder)(NSURLRequest *request, NSUInteger offset, NSData *data); diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.m index c249cfe33..7fcdbd6e5 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/FILE/FILEReader.m @@ -16,6 +16,7 @@ #import "MCSQueue.h" #import "MCSResponse.h" #import "MCSConsts.h" +#import "MCSUtils.h" static dispatch_queue_t mcs_queue; @@ -37,6 +38,8 @@ @interface FILEReader () @implementation FILEReader @synthesize readDataDecoder = _readDataDecoder; @synthesize response = _response; +@synthesize isReadingEndOfData = _isReadingEndOfData; + + (void)initialize { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -44,9 +47,13 @@ + (void)initialize { }); } -- (instancetype)initWithAsset:(__weak FILEAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate { +- (instancetype)initWithAsset:(__weak FILEAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^_Nullable)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate { self = [super init]; if ( self ) { +#ifdef DEBUG + MCSAssetReaderDebugLog(@"%@: <%p>.init { URL: %@, asset: %@, proxyURL: %@, headers: %@ };\n", NSStringFromClass(self.class), self, [MCSURLRecognizer.shared URLWithProxyURL:request.URL], asset, request.URL, request.allHTTPHeaderFields); +#endif + _asset = asset; _request = request; _networkTaskPriority = networkTaskPriority; @@ -91,7 +98,7 @@ - (void)prepare { if ( _isClosed || _isCalledPrepare ) return; - MCSAssetReaderDebugLog(@"%@: <%p>.prepare { assetName: %@, request: %@ };\n", NSStringFromClass(self.class), self, _asset.name, _request.mcs_description); + MCSAssetReaderDebugLog(@"%@: <%p>.prepare;\n", NSStringFromClass(self.class), self); _isCalledPrepare = YES; @@ -100,12 +107,9 @@ - (void)prepare { } - (NSData *)readDataOfLength:(NSUInteger)length { - if ( self.isReadingEndOfData ) - return nil; - __block NSData *data = nil; dispatch_barrier_sync(mcs_queue, ^{ - if ( _isClosed ) + if ( _isClosed || _isReadingEndOfData ) return; id current = self.current; @@ -164,7 +168,7 @@ - (NSUInteger)availableLength { - (NSUInteger)offset { __block NSUInteger offset = 0; dispatch_sync(mcs_queue, ^{ - offset = _subreaders.firstObject.range.location + _readLength; + offset = _range.location + _readLength; }); return offset; } @@ -178,11 +182,11 @@ - (BOOL)isPrepared { } - (BOOL)isReadingEndOfData { - __block BOOL isDone = NO; + __block BOOL isReadingEndOfData = NO; dispatch_sync(mcs_queue, ^{ - isDone = _subreaders.lastObject.isDone; + isReadingEndOfData = _isReadingEndOfData; }); - return isDone; + return isReadingEndOfData; } - (BOOL)isClosed { @@ -202,8 +206,6 @@ - (void)close { #pragma mark - - (void)_prepare { - NSUInteger totalLength = _asset.totalLength ?: NSUIntegerMax; - // `length`经常变动, 暂时这里排序吧 __auto_type contents = [_asset.contents sortedArrayUsingComparator:^NSComparisonResult(FILEContent *obj1, FILEContent *obj2) { if ( obj1.offset == obj2.offset ) @@ -211,79 +213,91 @@ - (void)_prepare { return obj1.offset < obj2.offset ? NSOrderedAscending : NSOrderedDescending; }]; - NSRange current = _request.mcs_range; - // bytes=-500 - if ( current.location == NSNotFound && current.length != NSNotFound ) - current.location = totalLength - current.length; - // bytes=9500- - else if ( current.location != NSNotFound && current.length == NSNotFound ) { - current.length = totalLength - current.location; - } - else if ( current.location == NSNotFound && current.length == NSNotFound ) { - current.location = 0; - current.length = totalLength; - } - - if ( current.location >= totalLength ) { - current.location = totalLength - 1; - } - - if ( NSMaxRange(current) >= totalLength ) { - current.length = totalLength - current.location; + NSUInteger totalLength = _asset.totalLength; + if ( totalLength == 0 ) { + // create single sub reader to load asset total length + NSURL *URL = [MCSURLRecognizer.shared URLWithProxyURL:_request.URL]; + NSMutableURLRequest *request = [_request mcs_requestWithRedirectURL:URL]; + _subreaders = @[ + [FILEContentReader.alloc initWithAsset:_asset request:request networkTaskPriority:_networkTaskPriority delegate:self] + ]; } - - if ( current.length == 0 ) { - [self _onError:[NSError mcs_errorWithCode:MCSInvalidRequestError userInfo:@{ - MCSErrorUserInfoObjectKey : _request, - MCSErrorUserInfoReasonKey : @"请求range参数错误!" - }]]; - return; - } - - _range = current; - - NSMutableArray> *subreaders = NSMutableArray.array; - NSURL *URL = [MCSURLRecognizer.shared URLWithProxyURL:_request.URL]; - for ( FILEContent *content in contents ) { - NSRange available = NSMakeRange(content.offset, content.length); - NSRange intersection = NSIntersectionRange(current, available); - if ( intersection.length != 0 ) { - // undownloaded part - NSRange leftRange = NSMakeRange(current.location, intersection.location - current.location); - if ( leftRange.length != 0 ) { - FILEContentReader *reader = [self _networkDataReaderWithURL:URL range:leftRange]; + else { + MCSRequestContentRange requestRange = MCSGetRequestContentRange(_request.mcs_headers); + NSRange current = NSMakeRange(0, 0); + // bytes=100-500 + if ( requestRange.start != NSNotFound && requestRange.end != NSNotFound ) { + NSUInteger location = requestRange.start; + NSUInteger length = totalLength > requestRange.end ? ((requestRange.end + 1) - location) : 0; + current = NSMakeRange(location, length); + } + // bytes=-500 + else if ( requestRange.start == NSNotFound && requestRange.end != NSNotFound ) { + NSUInteger length = totalLength > requestRange.end ? (requestRange.end + 1) : 0; + NSUInteger location = totalLength - length; + current = NSMakeRange(location, length); + } + // bytes=500- + else if ( requestRange.start != NSNotFound && requestRange.end == NSNotFound ) { + NSUInteger location = requestRange.start; + NSUInteger length = totalLength > location ? (totalLength - location) : 0; + current = NSMakeRange(location, length); + } + + if ( current.length == 0 ) { + [self _onError:[NSError mcs_errorWithCode:MCSInvalidRequestError userInfo:@{ + MCSErrorUserInfoObjectKey : _request, + MCSErrorUserInfoReasonKey : @"请求range参数错误!" + }]]; + return; + } + + _range = current; + + NSMutableArray> *subreaders = NSMutableArray.array; + NSURL *URL = [MCSURLRecognizer.shared URLWithProxyURL:_request.URL]; + for ( FILEContent *content in contents ) { + NSRange available = NSMakeRange(content.offset, content.length); + NSRange intersection = NSIntersectionRange(current, available); + if ( intersection.length != 0 ) { + // undownloaded part + NSRange leftRange = NSMakeRange(current.location, intersection.location - current.location); + if ( leftRange.length != 0 ) { + FILEContentReader *reader = [self _networkDataReaderWithURL:URL range:leftRange]; + [subreaders addObject:reader]; + } + + // downloaded part + NSRange matchedRange = NSMakeRange(NSMaxRange(leftRange), intersection.length); + NSRange fileRange = NSMakeRange(matchedRange.location - content.offset, intersection.length); + NSString *path = [_asset contentFilePathForFilename:content.filename]; + MCSAssetFileRead *reader = [MCSAssetFileRead.alloc initWithAsset:_asset inRange:matchedRange reference:content path:path readRange:fileRange delegate:self]; [subreaders addObject:reader]; + + // next part + current = NSMakeRange(NSMaxRange(intersection), NSMaxRange(_range) - NSMaxRange(intersection)); } - // downloaded part - NSRange matchedRange = NSMakeRange(NSMaxRange(leftRange), intersection.length); - NSRange fileRange = NSMakeRange(matchedRange.location - content.offset, intersection.length); - NSString *path = [_asset contentFilePathForFilename:content.filename]; - MCSAssetFileRead *reader = [MCSAssetFileRead.alloc initWithAsset:_asset inRange:matchedRange reference:content path:path readRange:fileRange delegate:self]; - [subreaders addObject:reader]; - - // next part - current = NSMakeRange(NSMaxRange(intersection), NSMaxRange(_request.mcs_range) - NSMaxRange(intersection)); + if ( current.length == 0 || available.location > NSMaxRange(current) ) break; } - if ( current.length == 0 || available.location > NSMaxRange(current) ) break; - } - - if ( current.length != 0 ) { - // undownloaded part - FILEContentReader *reader = [self _networkDataReaderWithURL:URL range:current]; - [subreaders addObject:reader]; + if ( current.length != 0 ) { + // undownloaded part + FILEContentReader *reader = [self _networkDataReaderWithURL:URL range:current]; + [subreaders addObject:reader]; + } + + _subreaders = subreaders.copy; } - _subreaders = subreaders.copy; - - MCSAssetReaderDebugLog(@"%@: <%p>.createSubreaders { range: %@, count: %lu };\n", NSStringFromClass(self.class), self, NSStringFromRange(_range), (unsigned long)_subreaders.count); + MCSAssetReaderDebugLog(@"%@: <%p>.createSubreaders { count: %lu };\n", NSStringFromClass(self.class), self, (unsigned long)_subreaders.count); [self _prepareNextReader]; } - (void)_prepareNextReader { if ( self.current == _subreaders.lastObject ) { + _isReadingEndOfData = YES; MCSAssetReaderDebugLog(@"%@: <%p>.done;\n", NSStringFromClass(self.class), self); [self _close]; return; @@ -294,7 +308,7 @@ - (void)_prepareNextReader { else _currentIndex += 1; - MCSAssetReaderDebugLog(@"%@: <%p>.subreader.prepare { sub: %@, count: %lu };\n", NSStringFromClass(self.class), self, self.current, (unsigned long)_subreaders.count); + MCSAssetReaderDebugLog(@"%@: <%p>.subreader.prepare { index: %ld, sub: %@, count: %lu };\n", NSStringFromClass(self.class), self, (long)_currentIndex, self.current, (unsigned long)_subreaders.count); [self.current prepare]; } @@ -314,6 +328,7 @@ - (void)_close { [reader close]; } + _subreaders = nil; _isClosed = YES; MCSAssetReaderDebugLog(@"%@: <%p>.close;\n", NSStringFromClass(self.class), self); diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.h b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.h index 7fa1614d1..ef564eba4 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.h +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface HLSReader : NSObject -- (instancetype)initWithAsset:(__weak HLSAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate; +- (instancetype)initWithAsset:(__weak HLSAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^_Nullable)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate; - (void)prepare; @property (nonatomic, copy, readonly, nullable) NSData *(^readDataDecoder)(NSURLRequest *request, NSUInteger offset, NSData *data); diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.m index e3c5fcb9f..4cd9012cc 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/HLS/HLSReader.m @@ -32,6 +32,8 @@ @implementation HLSReader @synthesize isClosed = _isClosed; @synthesize response = _response; @synthesize isPrepared = _isPrepared; +@synthesize isReadingEndOfData = _isReadingEndOfData; +@synthesize offset = _offset; + (void)initialize { static dispatch_once_t onceToken; @@ -40,9 +42,13 @@ + (void)initialize { }); } -- (instancetype)initWithAsset:(__weak HLSAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate { +- (instancetype)initWithAsset:(__weak HLSAsset *)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^_Nullable)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate { self = [super init]; if ( self ) { +#ifdef DEBUG + MCSAssetReaderDebugLog(@"%@: <%p>.init { URL: %@, asset: %@, proxyURL: %@, headers: %@ };\n", NSStringFromClass(self.class), self, [MCSURLRecognizer.shared URLWithProxyURL:request.URL], asset, request.URL, request.allHTTPHeaderFields); +#endif + _asset = asset; _request = request; _networkTaskPriority = networkTaskPriority; @@ -177,7 +183,13 @@ - (NSUInteger)availableLength { } - (NSUInteger)offset { - return self.reader.offset; + if ( self.reader != nil ) + return self.reader.offset; + __block NSUInteger offset = NO; + dispatch_sync(mcs_queue, ^{ + offset = _offset; + }); + return offset; } - (BOOL)isPrepared { @@ -189,7 +201,11 @@ - (BOOL)isPrepared { } - (BOOL)isReadingEndOfData { - return self.reader.isDone; + __block BOOL isReadingEndOfData = NO; + dispatch_sync(mcs_queue, ^{ + isReadingEndOfData = _isReadingEndOfData; + }); + return isReadingEndOfData; } - (BOOL)isClosed { @@ -206,7 +222,12 @@ - (void)_close { if ( _isClosed ) return; + _isReadingEndOfData = _reader.isDone; + _offset = _reader.offset; + [_reader close]; + + _reader = nil; _isClosed = YES; diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/MCSAssetManager.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/MCSAssetManager.m index 449c7dbb6..4a482e2e3 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/MCSAssetManager.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Asset/MCSAssetManager.m @@ -90,13 +90,8 @@ - (instancetype)init { @synthesize cacheCountLimit = _cacheCountLimit; - (void)setCacheCountLimit:(NSUInteger)cacheCountLimit { - dispatch_barrier_async(mcs_queue, ^{ - if ( cacheCountLimit != self->_cacheCountLimit ) { - self->_cacheCountLimit = cacheCountLimit; - if ( cacheCountLimit != 0 ) { - [self _removeAssetsForLimit:MCSLimitCount]; - } - } + dispatch_barrier_sync(mcs_queue, ^{ + _cacheCountLimit = cacheCountLimit; }); } @@ -110,13 +105,8 @@ - (NSUInteger)cacheCountLimit { @synthesize maxDiskAgeForCache = _maxDiskAgeForCache; - (void)setMaxDiskAgeForCache:(NSTimeInterval)maxDiskAgeForCache { - dispatch_barrier_async(mcs_queue, ^{ - if ( maxDiskAgeForCache != self->_maxDiskAgeForCache ) { - self->_maxDiskAgeForCache = maxDiskAgeForCache; - if ( maxDiskAgeForCache != 0 ) { - [self _removeAssetsForLimit:MCSLimitExpires]; - } - } + dispatch_barrier_sync(mcs_queue, ^{ + _maxDiskAgeForCache = maxDiskAgeForCache; }); } @@ -130,13 +120,8 @@ - (NSTimeInterval)maxDiskAgeForCache { @synthesize maxDiskSizeForCache = _maxDiskSizeForCache; - (void)setMaxDiskSizeForCache:(NSUInteger)maxDiskSizeForCache { - dispatch_barrier_async(mcs_queue, ^{ - if ( maxDiskSizeForCache != self->_maxDiskSizeForCache ) { - self->_maxDiskSizeForCache = maxDiskSizeForCache; - if ( maxDiskSizeForCache != 0 ) { - [self _removeAssetsForLimit:MCSLimitCacheDiskSpace]; - } - } + dispatch_barrier_sync(mcs_queue, ^{ + _maxDiskSizeForCache = maxDiskSizeForCache; }); } - (NSUInteger)maxDiskSizeForCache { @@ -149,13 +134,8 @@ - (NSUInteger)maxDiskSizeForCache { @synthesize reservedFreeDiskSpace = _reservedFreeDiskSpace; - (void)setReservedFreeDiskSpace:(NSUInteger)reservedFreeDiskSpace { - dispatch_barrier_async(mcs_queue, ^{ - if ( reservedFreeDiskSpace != self->_reservedFreeDiskSpace ) { - self->_reservedFreeDiskSpace = reservedFreeDiskSpace; - if ( reservedFreeDiskSpace != 0 ) { - [self _removeAssetsForLimit:MCSLimitFreeDiskSpace]; - } - } + dispatch_barrier_sync(mcs_queue, ^{ + _reservedFreeDiskSpace = reservedFreeDiskSpace; }); } diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSInterfaces.h b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSInterfaces.h index 1bdd740b4..d39a0ca90 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSInterfaces.h +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSInterfaces.h @@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - @protocol MCSAssetReader -- (instancetype)initWithAsset:(id)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate; +- (instancetype)initWithAsset:(id)asset request:(NSURLRequest *)request networkTaskPriority:(float)networkTaskPriority readDataDecoder:(NSData *(^_Nullable)(NSURLRequest *request, NSUInteger offset, NSData *data))readDataDecoder delegate:(id)delegate; - (void)prepare; @property (nonatomic, copy, readonly, nullable) NSData *(^readDataDecoder)(NSURLRequest *request, NSUInteger offset, NSData *data); diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSRootDirectory.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSRootDirectory.m index 99d67717a..81488225a 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSRootDirectory.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSRootDirectory.m @@ -10,31 +10,34 @@ #import "NSFileManager+MCS.h" @implementation MCSRootDirectory -+ (NSString *)path { - static NSString *path; +static NSString *mcs_path; ++ (void)initialize { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"com.SJMediaCacheServer.cache"]; - if ( ![NSFileManager.defaultManager fileExistsAtPath:path] ) { - [NSFileManager.defaultManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:NULL]; - const char *filePath = [path fileSystemRepresentation]; + mcs_path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"com.SJMediaCacheServer.cache"]; + if ( ![NSFileManager.defaultManager fileExistsAtPath:mcs_path] ) { + [NSFileManager.defaultManager createDirectoryAtPath:mcs_path withIntermediateDirectories:YES attributes:nil error:NULL]; + const char *filePath = [mcs_path fileSystemRepresentation]; const char *attrName = "com.apple.MobileBackup"; u_int8_t attrValue = 1; setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0); } }); - return path; +} + ++ (NSString *)path { + return mcs_path; } + (unsigned long long)size { - return [NSFileManager.defaultManager mcs_directorySizeAtPath:self.path]; + return [NSFileManager.defaultManager mcs_directorySizeAtPath:mcs_path]; } + (NSString *)assetPathForFilename:(NSString *)filename { - return [self.path stringByAppendingPathComponent:filename]; + return [mcs_path stringByAppendingPathComponent:filename]; } + (NSString *)databasePath { - return [self.path stringByAppendingPathComponent:@"mcs.db"]; + return [mcs_path stringByAppendingPathComponent:@"mcs.db"]; } @end diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Download/MCSDownload.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Download/MCSDownload.m index f94320894..c6cbd7e9d 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Download/MCSDownload.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Download/MCSDownload.m @@ -137,11 +137,11 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)task else if ( res.statusCode == 206 ) { NSRange range1 = MCSGetRequestNSRange(MCSGetRequestContentRange(task.currentRequest.allHTTPHeaderFields)); NSRange range2 = MCSGetResponseNSRange(MCSGetResponseContentRange(res)); - if ( !MCSNSRangeIsUndefined(range1) ) { - if ( MCSNSRangeIsUndefined(range2) || !NSEqualRanges(range1, range2) ) { + if ( !MCSNSRangeIsUndefined(range1) && !NSEqualRanges(range1, range2)) { + if ( !MCSNSRangeIsUndefined(range2) && NSMaxRange(range1) <= NSMaxRange(range2) ) { error = [NSError mcs_errorWithCode:MCSInvalidResponseError userInfo:@{ MCSErrorUserInfoObjectKey : response, - MCSErrorUserInfoReasonKey : [NSString stringWithFormat:@"响应无效: range(%@)无效!", NSStringFromRange(range2)] + MCSErrorUserInfoReasonKey : [NSString stringWithFormat:@"响应无效: requestRange(%@), responseRange(%@) range无效!", NSStringFromRange(range1), NSStringFromRange(range2)] }]; } } diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/ProxyServer/MCSProxyTask.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/ProxyServer/MCSProxyTask.m index e91b2803f..b27a7fcc1 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/ProxyServer/MCSProxyTask.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/ProxyServer/MCSProxyTask.m @@ -11,6 +11,7 @@ #import "MCSUtils.h" #import "MCSLogger.h" #import "NSURLRequest+MCS.h" +#import "MCSURLRecognizer.h" @interface MCSProxyTask () @property (nonatomic, weak) id delegate; @@ -28,6 +29,10 @@ - (instancetype)initWithRequest:(NSURLRequest *)request delegate:(id.init { URL: %@, proxyURL: %@, headers: %@ };\n", NSStringFromClass(self.class), self, [MCSURLRecognizer.shared URLWithProxyURL:request.URL], request.URL, request.allHTTPHeaderFields); +#endif + _request = request; _delegate = delegate; } @@ -36,7 +41,7 @@ - (instancetype)initWithRequest:(NSURLRequest *)request delegate:(id.prepare { request: %@ };\n", NSStringFromClass(self.class), self, _request.mcs_description); + MCSProxyTaskDebugLog(@"%@: <%p>.prepare;\n", NSStringFromClass(self.class), self); _startTime = MCSStartTime(); #endif diff --git a/Example/Pods/Target Support Files/Pods-SJVideoPlayer_Example/Pods-SJVideoPlayer_Example-frameworks.sh b/Example/Pods/Target Support Files/Pods-SJVideoPlayer_Example/Pods-SJVideoPlayer_Example-frameworks.sh new file mode 100755 index 000000000..38264b648 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-SJVideoPlayer_Example/Pods-SJVideoPlayer_Example-frameworks.sh @@ -0,0 +1,191 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +function on_error { + echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" +} +trap 'on_error $LINENO' ERR + +if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then + # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy + # frameworks to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" +BCSYMBOLMAP_DIR="BCSymbolMaps" + + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then + # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied + find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do + echo "Installing $f" + install_bcsymbolmap "$f" "$destination" + rm "$f" + done + rmdir "${source}/${BCSYMBOLMAP_DIR}" + fi + + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + elif [ -L "${binary}" ]; then + echo "Destination binary is symlinked..." + dirname="$(dirname "${binary}")" + binary="${dirname}/$(readlink "${binary}")" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + warn_missing_arch=${2:-true} + if [ -r "$source" ]; then + # Copy the dSYM into the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .dSYM "$source")" + binary_name="$(ls "$source/Contents/Resources/DWARF")" + binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}" + + # Strip invalid architectures from the dSYM. + if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then + strip_invalid_archs "$binary" "$warn_missing_arch" + fi + if [[ $STRIP_BINARY_RETVAL == 0 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM" + fi + fi +} + +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + warn_missing_arch=${2:-true} + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + if [[ "$warn_missing_arch" == "true" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + fi + STRIP_BINARY_RETVAL=1 + return + fi + stripped="" + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi + STRIP_BINARY_RETVAL=0 +} + +# Copies the bcsymbolmap files of a vendored framework +install_bcsymbolmap() { + local bcsymbolmap_path="$1" + local destination="${BUILT_PRODUCTS_DIR}" + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identity + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/AliyunPlayer.framework" + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/alivcffmpeg.framework" + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/AlivcConan.framework" + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/AliyunMediaDownloader.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/AliyunPlayer.framework" + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/alivcffmpeg.framework" + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/AlivcConan.framework" + install_framework "${PODS_ROOT}/AliPlayerSDK_iOS/AliyunMediaDownloader.framework" +fi +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Example/SJVideoPlayer.xcodeproj/project.pbxproj b/Example/SJVideoPlayer.xcodeproj/project.pbxproj index 475f1bc0a..4fa8d5d53 100644 --- a/Example/SJVideoPlayer.xcodeproj/project.pbxproj +++ b/Example/SJVideoPlayer.xcodeproj/project.pbxproj @@ -472,8 +472,8 @@ 7700905824988F6900A99906 /* UserHomepage */ = { isa = PBXGroup; children = ( - 7700905924988F6900A99906 /* SJDYUserHomepageViewController.m */, 7700905A24988F6900A99906 /* SJDYUserHomepageViewController.h */, + 7700905924988F6900A99906 /* SJDYUserHomepageViewController.m */, ); path = UserHomepage; sourceTree = ""; diff --git a/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate b/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate index 797e6392b..b75ec44f4 100644 Binary files a/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate and b/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m b/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m index e621d7f28..2abf58a14 100644 --- a/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m +++ b/Example/SJVideoPlayer/Demos/iPhone Demo/UITableView/SJUITableViewDemoViewController9.m @@ -31,8 +31,7 @@ - (void)coverItemWasTapped:(SJVideoTableViewCell *)cell { // 开启小浮窗(当播放器视图滑动消失时, 显示小浮窗视图) _player.floatSmallViewController.enabled = YES; // 自定义浮窗的初始位置 - _player.floatSmallViewController.floatViewAlignment = SJFloatViewAlignmentBottomRight; - _player.floatSmallViewController.floatViewInsets = UIEdgeInsetsMake(0, 0, 20, 12); +// _player.floatSmallViewController.layoutPosition = SJFloatViewLayoutPositionBottomRight; __weak typeof(self) _self = self; // 单击小浮窗时的回调 diff --git "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliViewController3.m" "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliViewController3.m" index 0a32d1c04..37762ed50 100644 --- "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliViewController3.m" +++ "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliViewController3.m" @@ -14,8 +14,11 @@ #if __has_include() #import + #endif +#import + @interface SJTestAliViewController3 () @property (nonatomic, strong) SJVideoPlayer *player; @end @@ -33,6 +36,7 @@ - (void)viewDidLoad { SJVideoPlayerURLAsset *asset = [SJVideoPlayerURLAsset.alloc initWithSource:source]; // asset.trialEndPosition = 30; // 试看30秒 _player.URLAsset = asset; + #else // 切换为 Aliplayer, 详见: https://github.com/changsanjiang/SJVideoPlayer/wiki/Use-AliPlayer [_player.prompt show:[NSAttributedString sj_UIKitText:^(id _Nonnull make) { @@ -58,6 +62,24 @@ - (IBAction)pause:(id)sender { [_player pause]; } +- (BOOL)shouldAutorotate { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [_player vc_viewDidAppear]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [_player vc_viewWillDisappear]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + [_player vc_viewDidDisappear]; +} @end diff --git "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliVodPlayerViewController.m" "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliVodPlayerViewController.m" index 914a60f5c..e712a08af 100644 --- "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliVodPlayerViewController.m" +++ "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestAliVodPlayerViewController.m" @@ -49,6 +49,25 @@ - (void)viewDidLoad { // Do any additional setup after loading the view from its nib. } + +- (BOOL)shouldAutorotate { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [_player vc_viewDidAppear]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [_player vc_viewWillDisappear]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + [_player vc_viewDidDisappear]; +} @end diff --git "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestIJKViewController2.m" "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestIJKViewController2.m" index 406882937..5a5c9393b 100644 --- "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestIJKViewController2.m" +++ "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestIJKViewController2.m" @@ -64,6 +64,27 @@ - (IBAction)pause:(id)sender { - (IBAction)next:(id)sender { _player.URLAsset = [SJVideoPlayerURLAsset.alloc initWithURL:VideoURL_Level1]; } + + + +- (BOOL)shouldAutorotate { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [_player vc_viewDidAppear]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [_player vc_viewWillDisappear]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + [_player vc_viewDidDisappear]; +} @end #pragma mark - diff --git "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestPLPlayerViewController.m" "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestPLPlayerViewController.m" index 21c893a5e..981bfc3eb 100644 --- "a/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestPLPlayerViewController.m" +++ "b/Example/SJVideoPlayer/Demos/\347\254\254\344\270\211\346\226\271\346\222\255\346\224\276\345\231\250/SJTestPLPlayerViewController.m" @@ -45,6 +45,25 @@ - (void)viewDidLoad { #endif } + +- (BOOL)shouldAutorotate { + return NO; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [_player vc_viewDidAppear]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [_player vc_viewWillDisappear]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + [_player vc_viewDidDisappear]; +} @end #pragma mark - diff --git a/SJVideoPlayer.podspec b/SJVideoPlayer.podspec index f98a4ed14..a498b9b5c 100644 --- a/SJVideoPlayer.podspec +++ b/SJVideoPlayer.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'SJVideoPlayer' - s.version = '3.2.8' + s.version = '3.2.9' s.summary = 'video player.' s.description = 'https://github.com/changsanjiang/SJVideoPlayer/blob/master/README.md' s.homepage = 'https://github.com/changsanjiang/SJVideoPlayer' @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.platform = :ios, '8.0' s.source = { :git => 'https://github.com/changsanjiang/SJVideoPlayer.git', :tag => "v#{s.version}" } s.requires_arc = true - s.dependency 'SJBaseVideoPlayer', '>= 3.4.3' + s.dependency 'SJBaseVideoPlayer', '>= 3.4.5' s.source_files = 'SJVideoPlayer/*.{h,m}' diff --git a/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m b/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m index 4bb8d4e89..2854833cb 100644 --- a/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m +++ b/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m @@ -36,15 +36,27 @@ @implementation SJScrollingTextMarqueeView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if ( self ) { - _margin = 28; - _scrollEnabled = YES; - self.clipsToBounds = YES; - [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_reset) name:UIApplicationWillEnterForegroundNotification object:nil]; - [self _setupViews]; + [self _init]; } return self; } +- (nullable instancetype)initWithCoder:(NSCoder *)coder { + self = [super initWithCoder:coder]; + if (self) { + [self _init]; + } + return self; +} + +- (void)_init { + _margin = 28; + _scrollEnabled = YES; + self.clipsToBounds = YES; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_reset) name:UIApplicationWillEnterForegroundNotification object:nil]; + [self _setupViews]; +} + - (void)dealloc { [NSNotificationCenter.defaultCenter removeObserver:self]; } diff --git a/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m b/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m index c7acfb6ef..f926f2aa6 100644 --- a/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m +++ b/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m @@ -51,12 +51,25 @@ @implementation SJProgressSlider { - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; - if ( !self ) return nil; + if ( self ) { + [self _init]; + } + return self; +} + +- (nullable instancetype)initWithCoder:(NSCoder *)coder { + self = [super initWithCoder:coder]; + if ( self ) { + [self _init]; + } + return self; +} + +- (void)_init { [self _setupDefaultValues]; [self _setupView]; [self _setupGestrue]; [self _needUpdateContainerCornerRadius]; - return self; } - (void)_setupDefaultValues { diff --git a/SJVideoPlayer/SJVideoPlayer.m b/SJVideoPlayer/SJVideoPlayer.m index ea95eddc3..577531d95 100644 --- a/SJVideoPlayer/SJVideoPlayer.m +++ b/SJVideoPlayer/SJVideoPlayer.m @@ -290,6 +290,7 @@ - (SJVideoDefinitionSwitchingInfoObserver *)sj_switchingInfoObserver { } break; } + [self _updateContentForDefinitionButtonItemIfNeeded]; }; } return _sj_switchingInfoObserver;