Skip to content

Commit

Permalink
Release 2.5.7
Browse files Browse the repository at this point in the history
- 修复剪辑控制层转场动画失效的问题
- `BaseVideoPlayer`兼容`AVPlayer.timeControlStatus`
  • Loading branch information
changsanjiang committed Apr 28, 2019
1 parent 0328ae1 commit 2c3f131
Show file tree
Hide file tree
Showing 67 changed files with 1,861 additions and 662 deletions.
2 changes: 1 addition & 1 deletion 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.5.5'
s.version = '2.5.7'
s.summary = 'video player.'
s.description = 'https://github.com/changsanjiang/SJVideoPlayer/blob/master/README.md'
s.homepage = 'https://github.com/changsanjiang/SJVideoPlayer'
Expand Down
6 changes: 3 additions & 3 deletions SJVideoPlayer/Adapters/SJEdgeControlLayerAdapters.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#else
#import "Masonry.h"
#endif
#if __has_include(<SJUIKit/SJAttributeWorker.h>)
#import <SJUIKit/SJAttributeWorker.h>
#if __has_include(<SJUIKit/SJAttributesFactory.h>)
#import <SJUIKit/SJAttributesFactory.h>
#else
#import "SJAttributeWorker.h"
#import "SJAttributesFactory.h"
#endif

#import "SJVideoPlayerControlMaskView.h"
Expand Down
78 changes: 45 additions & 33 deletions SJVideoPlayer/SJEdgeControlLayer/SJEdgeControlLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright © 2018 畅三江. All rights reserved.
//

#if __has_include(<SJUIKit/SJAttributeWorker.h>)
#import <SJUIKit/SJAttributeWorker.h>
#if __has_include(<SJUIKit/SJAttributesFactory.h>)
#import <SJUIKit/SJAttributesFactory.h>
#else
#import "SJAttributeWorker.h"
#import "SJAttributesFactory.h"
#endif

#if __has_include(<SJUIKit/NSObject+SJObserverHelper.h>)
Expand Down Expand Up @@ -342,9 +342,9 @@ - (void)_addItemsToBottomAdapter {
[self.bottomAdapter addItem:currentTimeItem];

// 时间分隔符
SJEdgeControlButtonItem *separatorItem = [[SJEdgeControlButtonItem alloc] initWithTitle:sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
SJEdgeControlButtonItem *separatorItem = [[SJEdgeControlButtonItem alloc] initWithTitle:[NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.append(@"/ ").font([UIFont systemFontOfSize:11]).textColor([UIColor whiteColor]).alignment(NSTextAlignmentCenter);
}) target:nil action:NULL tag:SJEdgeControlLayerBottomItem_Separator];
}] target:nil action:NULL tag:SJEdgeControlLayerBottomItem_Separator];
[self.bottomAdapter addItem:separatorItem];

// 全部时长
Expand Down Expand Up @@ -439,16 +439,17 @@ - (void)_updateTimeLabelFor_BottomAdapterWithCurrentTimeStr:(NSString *)currentT

if ( !durationTimeItem && !currentTimeItem ) return;

currentTimeItem.title = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
currentTimeItem.title = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.append(currentTimeStr).font([UIFont systemFontOfSize:11]).textColor([UIColor whiteColor]).alignment(NSTextAlignmentCenter);
});
}];

[_bottomAdapter updateContentForItemWithTag:SJEdgeControlLayerBottomItem_CurrentTime];

if ( ![durationStr isEqualToString:durationTimeItem.title.string?:@""] ) {
durationTimeItem.title = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
durationTimeItem.title = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.append(durationStr).font([UIFont systemFontOfSize:11]).textColor([UIColor whiteColor]).alignment(NSTextAlignmentCenter);
currentTimeItem.size = durationTimeItem.size = [self _timeLabelMaxWidthByDurationStr:durationStr];
});
}];
currentTimeItem.size = durationTimeItem.size = [self _timeLabelMaxWidthByDurationStr:durationStr];
[_bottomAdapter reload];
}
}
Expand All @@ -459,11 +460,9 @@ - (CGFloat)_timeLabelMaxWidthByDurationStr:(NSString *)durationStr {
NSString *ms = @"00:00";
NSString *hms = @"00:00:00";
NSString *format = (durationStr.length == ms.length)?ms:hms;
__block CGSize size = CGSizeZero;
sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
make.append(format).font([UIFont systemFontOfSize:11]).textColor([UIColor whiteColor]).alignment(NSTextAlignmentCenter);
size = make.size();
});
CGSize size = [[NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.append(format).font([UIFont systemFontOfSize:11]).textColor([UIColor whiteColor]);
}] sj_textSize];
return size.width;
}

Expand Down Expand Up @@ -709,13 +708,13 @@ - (void)_updateNetworkSpeedStrForLoadingView {
return;

if ( _showNetworkSpeedToLoadingView && !_videoPlayer.assetURL.isFileURL ) {
_loadingView.networkSpeedStr = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
_loadingView.networkSpeedStr = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
SJEdgeControlLayerSettings *settings = [SJEdgeControlLayerSettings commonSettings];
make.font(settings.loadingNetworkSpeedTextFont);
make.textColor(settings.loadingNetworkSpeedTextColor);
make.alignment(NSTextAlignmentCenter);
make.append(self.videoPlayer.networkSpeedStr);
});
}];
}
else {
_loadingView.networkSpeedStr = nil;
Expand Down Expand Up @@ -1204,13 +1203,19 @@ - (void)_top_updateTitleItem:(SJEdgeControlButtonItem *)titleItem {
[_topAdapter itemsIsHiddenWithRange:NSMakeRange([_topAdapter indexOfItemForTag:SJEdgeControlLayerTopItem_Title], _topAdapter.itemCount)]?16:0;
titleItem.numberOfLines = 1;
titleItem.insets = SJEdgeInsetsMake(left, right);
titleItem.title = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
make.append(title)
titleItem.title = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make
.font(SJEdgeControlLayerSettings.commonSettings.titleFont)
.textColor(SJEdgeControlLayerSettings.commonSettings.titleColor)
.shadow(CGSizeMake(0.5, 0.5), 1, [UIColor blackColor])
.lineBreakMode(NSLineBreakByTruncatingTail);
});

make.shadow(^(NSShadow * _Nonnull make) {
make.shadowOffset = CGSizeMake(0, 0.5);
make.shadowColor = UIColor.blackColor;
});

make.append(title);
}];
}

#pragma mark - update items -- LEFT
Expand Down Expand Up @@ -1271,12 +1276,17 @@ - (void)_bottom_updateFullItem:(SJEdgeControlButtonItem *)fullItem {
- (void)_bottom_updateLiveItem:(SJEdgeControlButtonItem *)liveItem {
if ( liveItem.hidden )
return;
liveItem.title = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
make.append(SJEdgeControlLayerSettings.commonSettings.liveText)
liveItem.title = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make
.font(SJEdgeControlLayerSettings.commonSettings.titleFont)
.textColor(SJEdgeControlLayerSettings.commonSettings.titleColor)
.shadow(CGSizeMake(0.5, 0.5), 1, [UIColor blackColor]);
});
.textColor(SJEdgeControlLayerSettings.commonSettings.titleColor);
make.append(SJEdgeControlLayerSettings.commonSettings.liveText);

make.shadow(^(NSShadow * _Nonnull make) {
make.shadowOffset = CGSizeMake(0, 0.5);
make.shadowColor = UIColor.blackColor;
});
}];
}

#pragma mark - update items CENTER
Expand All @@ -1287,10 +1297,13 @@ - (void)_center_updateReplayItem:(SJEdgeControlButtonItem *)replayItem {
UILabel *replayLabel = replayItem.customView;

dispatch_async(dispatch_get_global_queue(0, 0), ^{
__block CGRect bounds = CGRectZero;
NSAttributedString *attr = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
NSAttributedString *attr = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.alignment(NSTextAlignmentCenter).lineSpacing(6);

if ( setting.replayBtnImage ) {
make.append(setting.replayBtnImage, CGPointZero, CGSizeZero).alignment(NSTextAlignmentCenter);
make.appendImage(^(id<SJUTImageAttachment> _Nonnull make) {
make.image = setting.replayBtnImage;
});
}

if ( setting.replayBtnImage && 0 != setting.replayBtnTitle.length ) {
Expand All @@ -1301,12 +1314,11 @@ - (void)_center_updateReplayItem:(SJEdgeControlButtonItem *)replayItem {
make.append(setting.replayBtnTitle).font(setting.replayBtnFont)
.textColor(setting.replayBtnTitleColor);
}
make.alignment(NSTextAlignmentCenter).lineSpacing(6);
bounds = (CGRect){CGPointZero, make.size()};
});
}];

dispatch_async(dispatch_get_main_queue(), ^{
replayLabel.attributedText = attr;
replayLabel.bounds = bounds;
replayLabel.bounds = (CGRect){CGPointZero, [attr sj_textSize]};
[self.centerAdapter reload];
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#import "SJBaseVideoPlayer.h"
#endif

#if __has_include(<SJUIKit/SJAttributeWorker.h>)
#import <SJUIKit/SJAttributeWorker.h>
#if __has_include(<SJUIKit/SJAttributesFactory.h>)
#import <SJUIKit/SJAttributesFactory.h>
#else
#import "SJAttributeWorker.h"
#import "SJAttributesFactory.h"
#endif

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -370,11 +370,14 @@ - (void)_uploadResultIfNeeded {
}

- (void)_updatePromptLabelText:(NSString *)text {
_promptLabel.attributedText = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
_promptLabel.attributedText = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.font([UIFont systemFontOfSize:12]).textColor([UIColor whiteColor]);
make.append(text);
make.shadow(CGSizeMake(0.5, 0.5), 1, [UIColor blackColor]);
});
make.shadow(^(NSShadow * _Nonnull make) {
make.shadowColor = UIColor.blackColor;
make.shadowOffset = CGSizeMake(0, 0.5);
});
}];
}

- (void)_cancel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#import "Masonry.h"
#endif

#if __has_include(<SJUIKit/SJAttributeWorker.h>)
#import <SJUIKit/SJAttributeWorker.h>
#if __has_include(<SJUIKit/SJAttributesFactory.h>)
#import <SJUIKit/SJAttributesFactory.h>
#else
#import "SJAttributeWorker.h"
#import "SJAttributesFactory.h"
#endif

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -34,14 +34,20 @@ - (void)setShareItems:(nullable NSArray<SJFilmEditingResultShareItem *> *)shareI
[shareItems enumerateObjectsUsingBlock:^(SJFilmEditingResultShareItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.titleLabel.numberOfLines = 0;
[btn setAttributedTitle:sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
make.insertImage(obj.image, 0, CGPointZero, CGSizeMake(40, 40));
make.insertText(@"\n", -1);
make.insertText(obj.title, -1);
make.lineSpacing(8);
make.alignment(NSTextAlignmentCenter);
make.font([UIFont systemFontOfSize:10]).textColor([UIColor whiteColor]);
}) forState:UIControlStateNormal];
[btn setAttributedTitle:[NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.lineSpacing(8)
.alignment(NSTextAlignmentCenter)
.font([UIFont systemFontOfSize:10])
.textColor([UIColor whiteColor]);

make.appendImage(^(id<SJUTImageAttachment> _Nonnull make) {
make.image = obj.image;
make.bounds = CGRectMake(0, 0, 40, 40);
});

make.append(@"\n");
make.append(obj.title);
}] forState:UIControlStateNormal];
btn.tag = idx;
[btn addTarget:self action:@selector(clickedBtn:) forControlEvents:UIControlEventTouchUpInside];

Expand Down
Loading

0 comments on commit 2c3f131

Please sign in to comment.