Skip to content

Commit

Permalink
Showing 70 changed files with 2,208 additions and 4,370 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,12 +13,12 @@ pod 'SJVideoPlayer'
# The base player, without the control layer, can be used if you need a custom control layer.
pod 'SJBaseVideoPlayer'

# 天朝
# 天朝
# 如果网络不行安装不了, 可改成以下方式进行安装
pod 'SJBaseVideoPlayer', :git => 'https://gitee.com/changsanjiang/SJBaseVideoPlayer.git'
pod 'SJVideoPlayer', :git => 'https://gitee.com/changsanjiang/SJVideoPlayer.git'
pod 'SJObserverHelper', :git => 'https://gitee.com/changsanjiang/SJObserverHelper.git'
pod 'SJAttributesFactory', :git => 'https://gitee.com/changsanjiang/SJAttributesFactory.git'
pod 'SJUIFactory', :git => 'https://gitee.com/changsanjiang/SJUIFactory.git'
$ pod update --no-repo-update (不要用 pod install 了, 用这个命令安装)
```
- [Base Video Player](https://github.com/changsanjiang/SJBaseVideoPlayer)
5 changes: 2 additions & 3 deletions SJVideoPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'SJVideoPlayer'
s.version = '2.4.2'
s.version = '2.4.3'
s.summary = 'video player.'
s.description = 'https://github.com/changsanjiang/SJVideoPlayer/blob/master/README.md'
s.homepage = 'https://github.com/changsanjiang/SJVideoPlayer'
@@ -11,8 +11,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/changsanjiang/SJVideoPlayer.git', :tag => "v#{s.version}" }
s.requires_arc = true
s.dependency 'Masonry'
s.dependency 'SJBaseVideoPlayer', '2.1.4'
s.dependency 'SJUIFactory'
s.dependency 'SJBaseVideoPlayer', '2.1.6'
s.dependency 'SJAttributesFactory'

s.source_files = 'SJVideoPlayer/*.{h,m}'
Original file line number Diff line number Diff line change
@@ -7,11 +7,6 @@
//

#import "SJVideoPlayerDraggingProgressView.h"
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#if __has_include(<Masonry/Masonry.h>)
#import <Masonry/Masonry.h>
#else
@@ -185,7 +180,6 @@ - (void)_setupViews {
[_contentView addSubview:self.durationTimeLabel];
[_contentView addSubview:self.previewImageView];

[SJUIFactory regulate:_contentView cornerRadius:8];
_contentView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
[_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.offset(0);
@@ -209,6 +203,7 @@ - (void)_setupViews {
- (UIView *)contentView {
if ( _contentView ) return _contentView;
_contentView = [UIView new];
_contentView.layer.cornerRadius = 8;
return _contentView;
}

@@ -223,33 +218,43 @@ - (SJProgressSlider *)progressSlider {

- (UIImageView *)directionImageView {
if ( _directionImageView ) return _directionImageView;
_directionImageView = [SJUIImageViewFactory imageViewWithViewMode:UIViewContentModeScaleAspectFit];
_directionImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_directionImageView.contentMode = UIViewContentModeScaleAspectFit;
return _directionImageView;
}

- (UIImageView *)previewImageView {
if ( _previewImageView ) return _previewImageView;
_previewImageView = [SJUIImageViewFactory imageViewWithViewMode:UIViewContentModeScaleAspectFit];
[SJUIFactory regulate:_previewImageView cornerRadius:8];
_previewImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_previewImageView.contentMode = UIViewContentModeScaleAspectFit;
_previewImageView.layer.cornerRadius = 8;
_previewImageView.layer.masksToBounds = YES;
return _previewImageView;
}

- (UILabel *)shiftTimeLabel {
if ( _shiftTimeLabel ) return _shiftTimeLabel;
_shiftTimeLabel = [SJUILabelFactory labelWithFont:[UIFont systemFontOfSize:13]];
_shiftTimeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_shiftTimeLabel.font = [UIFont systemFontOfSize:13];
_shiftTimeLabel.textColor = [UIColor whiteColor];
_shiftTimeLabel.textAlignment = NSTextAlignmentRight;
return _shiftTimeLabel;
}

- (UILabel *)separatorLabel {
if ( _separatorLabel ) return _separatorLabel;
_separatorLabel = [SJUILabelFactory labelWithText:@"/" textColor:[UIColor whiteColor] font:self.shiftTimeLabel.font];
_separatorLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_separatorLabel.font = [UIFont systemFontOfSize:13];
_separatorLabel.textColor = [UIColor whiteColor];
_separatorLabel.text = @"/";
return _separatorLabel;
}

- (UILabel *)durationTimeLabel {
if ( _durationTimeLabel ) return _durationTimeLabel;
_durationTimeLabel = [SJUILabelFactory labelWithFont:self.shiftTimeLabel.font textColor:[UIColor whiteColor]];
_durationTimeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_durationTimeLabel.font = [UIFont systemFontOfSize:13];
_durationTimeLabel.textColor = [UIColor whiteColor];
_durationTimeLabel.textAlignment = NSTextAlignmentLeft;
return _durationTimeLabel;
}
Original file line number Diff line number Diff line change
@@ -7,11 +7,6 @@
//

#import "SJVideoPlayerPreviewCollectionViewCell.h"
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#if __has_include(<Masonry/Masonry.h>)
#import <Masonry/Masonry.h>
#else
@@ -51,7 +46,8 @@ - (void)_collectionSetupView {

- (UIImageView *)imageView {
if ( _imageView ) return _imageView;
_imageView = [SJUIImageViewFactory imageViewWithImageName:@"" viewMode:UIViewContentModeScaleAspectFill];
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
return _imageView;
}
@end
41 changes: 18 additions & 23 deletions SJVideoPlayer/SJEdgeControlLayer/View/SJVideoPlayerPreviewView.m
Original file line number Diff line number Diff line change
@@ -7,49 +7,44 @@
//

#import "SJVideoPlayerPreviewView.h"
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#if __has_include(<Masonry/Masonry.h>)
#import <Masonry/Masonry.h>
#else
#import "Masonry.h"
#endif



static NSString *SJVideoPlayerPreviewCollectionViewCellID = @"SJVideoPlayerPreviewCollectionViewCell";

@interface SJVideoPlayerPreviewView ()<UICollectionViewDelegate, UICollectionViewDataSource>
struct SJPreviewBounds {
CGFloat maxWidth;
CGFloat minWidth;
CGFloat height;
};

@interface SJVideoPlayerPreviewView ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong, readonly) UICollectionView *collectionView;

@property (nonatomic, readonly) CGFloat maxHeight;

@property (nonatomic) struct SJPreviewBounds previewBounds;
@end

@implementation SJVideoPlayerPreviewView
@synthesize maxHeight = _maxHeight;
@synthesize collectionView = _collectionView;

- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if ( !self ) return nil;
[self _previewSetupView];
CGFloat screenW = UIScreen.mainScreen.bounds.size.width;
CGFloat screenH = UIScreen.mainScreen.bounds.size.height;
CGFloat min = MIN(screenW, screenH);
CGFloat max = MAX(screenW, screenH);
_previewBounds = (struct SJPreviewBounds){max, min, ceil(min * 0.25)};
[self _setupViews];
return self;
}

- (CGFloat)maxHeight {
if ( _maxHeight != 0 ) return _maxHeight;
_maxHeight = ceil(SJScreen_Min() * 0.25);
return _maxHeight;
}

- (CGSize)intrinsicContentSize {
if ( _fullscreen ) return CGSizeMake(SJScreen_Max(), self.maxHeight);
else return CGSizeMake(SJScreen_Min(), self.maxHeight);
if ( _fullscreen )
return CGSizeMake(_previewBounds.maxWidth, _previewBounds.height);
return CGSizeMake(_previewBounds.minWidth, _previewBounds.height);
}

- (void)setPreviewImages:(NSArray<id<SJVideoPlayerPreviewInfo>> *)previewImages {
@@ -64,7 +59,7 @@ - (void)setFullscreen:(BOOL)fullscreen {

#pragma mark

- (void)_previewSetupView {
- (void)_setupViews {
[self addSubview:self.collectionView];
[_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self->_collectionView.superview);
@@ -98,7 +93,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGSize imageSize = _previewImages.firstObject.image.size;
CGFloat rate = imageSize.width / imageSize.height;
CGFloat height = floor(self.maxHeight - (collectionView.contentInset.top + collectionView.contentInset.bottom));
CGFloat height = floor(_previewBounds.height - (collectionView.contentInset.top + collectionView.contentInset.bottom));
CGFloat width = floor(rate * height);
return CGSizeMake( width, height );
}
Original file line number Diff line number Diff line change
@@ -17,11 +17,6 @@
#else
#import "SJAttributeWorker.h"
#endif
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#import "SJVideoPlayerMoreSetting+Exe.h"
#import "SJVideoPlayerMoreSettingSecondary.h"

@@ -79,7 +74,8 @@ - (void)_SJVideoPlayerMoreSettingTwoSettingsCellSetupUI {

- (UIButton *)itemBtn {
if ( _itemBtn ) return _itemBtn;
_itemBtn = [SJUIButtonFactory buttonWithTarget:self sel:@selector(clickedBtn:)];
_itemBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_itemBtn addTarget:self action:@selector(clickedBtn:) forControlEvents:UIControlEventTouchUpInside];
_itemBtn.titleLabel.numberOfLines = 0;
_itemBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
return _itemBtn;
Original file line number Diff line number Diff line change
@@ -14,11 +14,6 @@
#endif
#import "SJVideoPlayerMoreSettingsSecondaryHeaderView.h"
#import "SJVideoPlayerMoreSettingSecondary.h"
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif

@interface SJVideoPlayerMoreSettingSecondaryView (ColDataSourceMethods)<UICollectionViewDataSource>
@end
@@ -57,7 +52,6 @@ - (void)setTwoLevelSettings:(SJVideoPlayerMoreSetting *)twoLevelSettings {
- (void)_secondarySettingSetupUI {
[self addSubview:self.colView];
[_colView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.offset(ceil(SJScreen_Max() * 0.4));
make.top.left.bottom.offset(0);
if (@available(iOS 11.0, *)) {
make.right.equalTo(self.mas_safeAreaLayoutGuideRight);
Original file line number Diff line number Diff line change
@@ -17,11 +17,6 @@
#else
#import "SJAttributeWorker.h"
#endif
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#import "SJVideoPlayerMoreSetting+Exe.h"


@@ -80,7 +75,8 @@ - (void)_SJVideoPlayerMoreSettingsColCellSetupUI {

- (UIButton *)itemBtn {
if ( _itemBtn ) return _itemBtn;
_itemBtn = [SJUIButtonFactory buttonWithTarget:self sel:@selector(clickedBtn:)];
_itemBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_itemBtn addTarget:self action:@selector(clickedBtn:) forControlEvents:UIControlEventTouchUpInside];
_itemBtn.titleLabel.numberOfLines = 0;
_itemBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
return _itemBtn;
Original file line number Diff line number Diff line change
@@ -12,11 +12,6 @@
#else
#import "Masonry.h"
#endif
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#import "SJVideoPlayerMoreSetting.h"
#import "SJVideoPlayerMoreSettingSecondaryView.h"
#import "SJVideoPlayerMoreSettingSecondary.h"
@@ -73,7 +68,8 @@ - (UIView *)line {

- (UILabel *)titleLabel {
if ( _titleLabel ) return _titleLabel;
_titleLabel = [SJUILabelFactory labelWithText:@"" textColor:[SJVideoPlayerMoreSettingSecondary titleColor] alignment:NSTextAlignmentLeft font:[UIFont systemFontOfSize:10]];
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_titleLabel.textColor = [SJVideoPlayerMoreSettingSecondary titleColor];
_titleLabel.font = [UIFont systemFontOfSize:[SJVideoPlayerMoreSettingSecondary topTitleFontSize]];
return _titleLabel;
}
Original file line number Diff line number Diff line change
@@ -13,11 +13,6 @@
#else
#import "Masonry.h"
#endif
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#import "UIView+SJVideoPlayerSetting.h"

@interface SJVideoPlayerMoreSettingsSlidersView ()<SJProgressSliderDelegate>
@@ -39,7 +34,8 @@ + (CGFloat)itemHeight {
}

- (CGSize)intrinsicContentSize {
return CGSizeMake(ceil(SJScreen_Max() * 0.4), [[self class] itemHeight] * 3);
CGFloat max = MAX(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height);
return CGSizeMake(ceil(max * 0.4), [[self class] itemHeight] * 3);
}

- (instancetype)initWithFrame:(CGRect)frame {
Original file line number Diff line number Diff line change
@@ -8,20 +8,13 @@

#import <UIKit/UIKit.h>
#import "SJMoreSettingsSlidersViewModel.h"

NS_ASSUME_NONNULL_BEGIN

@class SJVideoPlayerMoreSetting;

NS_ASSUME_NONNULL_BEGIN
@interface SJVideoPlayerMoreSettingsView : UIView

@property (nonatomic, strong, nullable) NSArray<SJVideoPlayerMoreSetting *> *moreSettings;

@property (nonatomic, strong, nullable) SJMoreSettingsSlidersViewModel *footerViewModel;

@property (nonatomic) BOOL fullscreen;

- (void)update;
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -13,11 +13,6 @@
#else
#import "Masonry.h"
#endif
#if __has_include(<SJUIFactory/SJUIFactory.h>)
#import <SJUIFactory/SJUIFactory.h>
#else
#import "SJUIFactory.h"
#endif
#import "SJVideoPlayerMoreSettingsFooterView.h"


@@ -42,7 +37,7 @@ @implementation SJVideoPlayerMoreSettingsView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if ( !self ) return nil;
[self _moreSettingsViewSetupUI];
[self _setupViews];
return self;
}

@@ -65,18 +60,17 @@ - (void)setMoreSettings:(NSArray<SJVideoPlayerMoreSetting *> *)moreSettings {
[self.colView reloadData];
}

- (void)_moreSettingsViewSetupUI {
- (void)_setupViews {
[self addSubview:self.colView];
[_colView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.offset(ceil(SJScreen_Max() * 0.4));
make.width.offset(self.slidersView.intrinsicContentSize.width);
make.top.left.bottom.offset(0);
if (@available(iOS 11.0, *)) {
make.right.equalTo(self.mas_safeAreaLayoutGuideRight);
} else {
make.right.offset(0);
}
}];
[self slidersView];
}

- (UICollectionView *)colView {
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ - (SJVideoPlayerMoreSettingSecondaryView *)moreSecondarySettingView {
_moreSecondarySettingView.sjv_disappearDirection = SJViewDisappearAnimation_Right;
[self addSubview:_moreSecondarySettingView];
[_moreSecondarySettingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.right.offset(0);
make.edges.equalTo(self.moreSettingsView);
}];
__weak typeof(self) _self = self;
_moreSecondarySettingView.settingRecroder = [[SJVideoPlayerControlSettingRecorder alloc] initWithSettings:^(SJEdgeControlLayerSettings * _Nonnull setting) {
Loading

0 comments on commit 880269c

Please sign in to comment.