Skip to content

Commit

Permalink
Release 3.3.6
Browse files Browse the repository at this point in the history
- 现在可以在ScrollView中添加播放器了
- 修复了小浮窗视图不能拖动的问题
  • Loading branch information
changsanjiang committed Jul 8, 2020
1 parent 072fe39 commit 6fb5f51
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 107 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.5'
s.version = '3.3.6'
s.summary = 'video player.'
s.description = 'https://github.com/changsanjiang/SJBaseVideoPlayer/blob/master/README.md'
s.homepage = 'https://github.com/changsanjiang/SJBaseVideoPlayer'
Expand Down
4 changes: 1 addition & 3 deletions SJBaseVideoPlayer/AVPlayer/Core/SJAVMediaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ - (void)_postNotification:(NSNotificationName)name {
}

- (void)_willSeeking:(CMTime)time {
if ( self.seekingInfo.isSeeking ) {
[_avPlayer.currentItem cancelPendingSeeks];
}
[_avPlayer.currentItem cancelPendingSeeks];

self.isPlaybackFinished = NO;
_seekingInfo.time = time;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ - (SJAssetStatus)assetStatus {
}

- (NSTimeInterval)currentTime {
return _currentPlayer.currentTime;
return _currentPlayer.seekingInfo.isSeeking ? CMTimeGetSeconds(_currentPlayer.seekingInfo.time) : _currentPlayer.currentTime;
}

- (NSTimeInterval)duration {
Expand Down
6 changes: 6 additions & 0 deletions SJBaseVideoPlayer/Common/Implements/SJPlayModel+SJPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#import "SJPlayModel.h"

NS_ASSUME_NONNULL_BEGIN
@interface SJScrollViewPlayModel : SJPlayModel
- (instancetype)initWithScrollView:(__weak UIScrollView *)scrollView;

@property (nonatomic, weak, readonly, nullable) UIScrollView *scrollView;
@end

@interface SJTableViewCellPlayModel : SJPlayModel
- (instancetype)initWithTableView:(__weak UITableView *)tableView indexPath:(NSIndexPath *)indexPath;

Expand Down
10 changes: 8 additions & 2 deletions SJBaseVideoPlayer/Common/Implements/SJPlayModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - UIView

- (instancetype)init;

#pragma mark - UIScrollView

/// - UIScrollView
/// - PlayerSuperview<SJPlayModelPlayerSuperview>
/// - player
+ (instancetype)playModelWithScrollView:(__weak UIScrollView *)scrollView;

#pragma mark - UITableView

Expand Down Expand Up @@ -127,8 +134,7 @@ NS_ASSUME_NONNULL_BEGIN

#pragma mark -

- (BOOL)isPlayInTableView;
- (BOOL)isPlayInCollectionView;
- (BOOL)isPlayInScrollView;
- (nullable UIView *)playerSuperview;
- (nullable __kindof UIScrollView *)inScrollView;
- (nullable NSIndexPath *)indexPath;
Expand Down
102 changes: 47 additions & 55 deletions SJBaseVideoPlayer/Common/Implements/SJPlayModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ - (instancetype)init {
return self;
}

+ (instancetype)playModelWithScrollView:(__weak UIScrollView *)scrollView {
return [SJScrollViewPlayModel.alloc initWithScrollView:scrollView];
}

+ (instancetype)playModelWithTableView:(__weak UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
return [SJTableViewCellPlayModel.alloc initWithTableView:tableView indexPath:indexPath];
}
Expand Down Expand Up @@ -52,14 +56,36 @@ + (instancetype)playModelWithCollectionView:(UICollectionView *__weak)collection
}


- (BOOL)isPlayInTableView { return NO; }
- (BOOL)isPlayInCollectionView { return NO; }
- (BOOL)isPlayInScrollView { return NO; }
- (nullable UIView *)playerSuperview { return nil; }
- (nullable __kindof UIScrollView *)inScrollView { return nil; }
- (nullable NSIndexPath *)indexPath { return nil; }
@end


@implementation SJScrollViewPlayModel
- (instancetype)initWithScrollView:(__weak UIScrollView *)scrollView {
self = [super init];
if ( self ) {
_scrollView = scrollView;
}
return self;
}

- (BOOL)isPlayInScrollView {
return YES;
}

- (nullable UIView *)playerSuperview {
return [_scrollView viewWithProtocol:@protocol(SJPlayModelPlayerSuperview)];
}

- (nullable __kindof UIScrollView *)inScrollView {
return _scrollView;
}
@end


@implementation SJTableViewCellPlayModel
- (instancetype)initWithTableView:(__weak UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
self = [super init];
Expand All @@ -70,12 +96,9 @@ - (instancetype)initWithTableView:(__weak UITableView *)tableView indexPath:(NSI
return self;
}

- (BOOL)isPlayInTableView {
- (BOOL)isPlayInScrollView {
return YES;
}
- (BOOL)isPlayInCollectionView {
return NO;
}
- (nullable UIView *)playerSuperview {
return [_tableView viewWithProtocol:@protocol(SJPlayModelPlayerSuperview) atIndexPath:_indexPath];
}
Expand All @@ -95,12 +118,9 @@ - (instancetype)initWithTableView:(UITableView *__weak)tableView tableHeaderView
return self;
}

- (BOOL)isPlayInTableView {
- (BOOL)isPlayInScrollView {
return YES;
}
- (BOOL)isPlayInCollectionView {
return NO;
}
- (nullable UIView *)playerSuperview {
return [_tableHeaderView viewWithProtocol:@protocol(SJPlayModelPlayerSuperview)];
}
Expand All @@ -120,12 +140,9 @@ - (instancetype)initWithTableView:(UITableView *__weak)tableView tableFooterView
return self;
}

- (BOOL)isPlayInTableView {
- (BOOL)isPlayInScrollView {
return YES;
}
- (BOOL)isPlayInCollectionView {
return NO;
}
- (nullable UIView *)playerSuperview {
return [_tableFooterView viewWithProtocol:@protocol(SJPlayModelPlayerSuperview)];
}
Expand All @@ -145,12 +162,9 @@ - (instancetype)initWithTableView:(__weak UITableView *)tableView inHeaderForSec
return self;
}

- (BOOL)isPlayInTableView {
- (BOOL)isPlayInScrollView {
return YES;
}
- (BOOL)isPlayInCollectionView {
return NO;
}
- (nullable UIView *)playerSuperview {
return [_tableView viewWithProtocol:@protocol(SJPlayModelPlayerSuperview) inHeaderForSection:_section];
}
Expand All @@ -170,12 +184,9 @@ - (instancetype)initWithTableView:(__weak UITableView *)tableView inFooterForSec
return self;
}

- (BOOL)isPlayInTableView {
- (BOOL)isPlayInScrollView {
return YES;
}
- (BOOL)isPlayInCollectionView {
return NO;
}
- (nullable UIView *)playerSuperview {
return [_tableView viewWithProtocol:@protocol(SJPlayModelPlayerSuperview) inFooterForSection:_section];
}
Expand Down Expand Up @@ -227,11 +238,7 @@ - (void)setNextPlayModel:(nullable __kindof SJPlayModel *)nextPlayModel {
}
}

- (BOOL)isPlayInTableView {
return NO;
}

- (BOOL)isPlayInCollectionView {
- (BOOL)isPlayInScrollView {
return YES;
}

Expand Down Expand Up @@ -275,11 +282,7 @@ - (instancetype)initWithCollectionView:(__weak UICollectionView *)collectionView
return self;
}

- (BOOL)isPlayInTableView {
return NO;
}

- (BOOL)isPlayInCollectionView {
- (BOOL)isPlayInScrollView {
return YES;
}

Expand All @@ -301,12 +304,8 @@ - (instancetype)initWithCollectionView:(__weak UICollectionView *)collectionView
}
return self;
}

- (BOOL)isPlayInTableView {
return NO;
}

- (BOOL)isPlayInCollectionView {

- (BOOL)isPlayInScrollView {
return YES;
}

Expand Down Expand Up @@ -396,8 +395,7 @@ - (instancetype)initWithPlayerSuperviewTag:(NSInteger)playerSuperviewTag
_tableView = tableView;
return self;
}
- (BOOL)isPlayInTableView { return YES; }
- (BOOL)isPlayInCollectionView { return NO; }
- (BOOL)isPlayInScrollView { return YES; }
- (nullable UIView *)playerSuperview {
return [[self.tableView cellForRowAtIndexPath:self.indexPath] viewWithTag:self.playerSuperviewTag];
}
Expand Down Expand Up @@ -428,8 +426,7 @@ - (instancetype)initWithPlayerSuperviewTag:(NSInteger)playerSuperviewTag
_collectionView = collectionView;
return self;
}
- (BOOL)isPlayInTableView { return NO; }
- (BOOL)isPlayInCollectionView { return YES; }
- (BOOL)isPlayInScrollView { return YES; }
- (nullable UIView *)playerSuperview {
return [[self.collectionView cellForItemAtIndexPath:self.indexPath] viewWithTag:self.playerSuperviewTag];
}
Expand All @@ -452,8 +449,7 @@ - (instancetype)initWithPlayerSuperview:(UIView * _Nonnull __weak)playerSupervie
return self;
}

- (BOOL)isPlayInTableView { return YES; }
- (BOOL)isPlayInCollectionView { return NO; }
- (BOOL)isPlayInScrollView { return YES; }
- (nullable __kindof UIScrollView *)inScrollView {
return _tableView;
}
Expand Down Expand Up @@ -485,9 +481,8 @@ - (instancetype)initWithPlayerSuperviewTag:(NSInteger)playerSuperviewTag
_tableView = tableView;
return self;
}

- (BOOL)isPlayInTableView { return NO; }
- (BOOL)isPlayInCollectionView { return YES; }

- (BOOL)isPlayInScrollView { return YES; }
- (nullable UIView *)playerSuperview {
return [[self.collectionView cellForItemAtIndexPath:self.indexPath] viewWithTag:self.playerSuperviewTag];
}
Expand Down Expand Up @@ -525,9 +520,8 @@ - (instancetype)initWithPlayerSuperviewTag:(NSInteger)playerSuperviewTag
_tableView = tableView;
return self;
}

- (BOOL)isPlayInTableView { return NO; }
- (BOOL)isPlayInCollectionView { return YES; }

- (BOOL)isPlayInScrollView { return YES; }
- (nullable UIView *)playerSuperview {
return [[self.collectionView cellForItemAtIndexPath:self.indexPath] viewWithTag:self.playerSuperviewTag];
}
Expand Down Expand Up @@ -560,9 +554,8 @@ - (instancetype)initWithPlayerSuperviewTag:(NSInteger)playerSuperviewTag
_rootCollectionView = rootCollectionView;
return self;
}

- (BOOL)isPlayInTableView { return NO; }
- (BOOL)isPlayInCollectionView { return YES; }

- (BOOL)isPlayInScrollView { return YES; }
- (nullable UIView *)playerSuperview {
return [[[self collectionView] cellForItemAtIndexPath:self.indexPath] viewWithTag:self.playerSuperviewTag];
}
Expand Down Expand Up @@ -593,8 +586,7 @@ - (instancetype)initWithPlayerSuperviewTag:(NSInteger)playerSuperviewTag
return self;
}

- (BOOL)isPlayInTableView { return YES; }
- (BOOL)isPlayInCollectionView { return NO; }
- (BOOL)isPlayInScrollView { return YES; }
- (UIView *_Nullable)playerSuperview {
return _isHeader?[[[self tableView] headerViewForSection:_inSection] viewWithTag:_playerSuperviewTag]:
[[[self tableView] footerViewForSection:_inSection] viewWithTag:_playerSuperviewTag];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak, nullable) id <SJPlayModelPropertiesObserverDelegate> delegate;

@property (nonatomic, readonly) BOOL isAppeared;
@property (nonatomic, readonly) BOOL isTouchedTableView;
@property (nonatomic, readonly) BOOL isTouchedCollectionView;
@property (nonatomic, readonly) BOOL isPlayInTableView;
@property (nonatomic, readonly) BOOL isPlayInCollectionView;
@property (nonatomic, readonly) BOOL isTouched;
@property (nonatomic, readonly) BOOL isPlayInScrollView;
@property (nonatomic, readonly) BOOL isScrolling;

- (void)refreshAppearState;
Expand Down
Loading

0 comments on commit 6fb5f51

Please sign in to comment.