From c5d4889ed6a55b1aec40e857042cd4746d198144 Mon Sep 17 00:00:00 2001 From: SanJiang Date: Sat, 10 Apr 2021 14:39:10 +0800 Subject: [PATCH] update SJScrollingTextMarqueeView --- .../Implements/SJScrollingTextMarqueeView.h | 1 + .../Implements/SJScrollingTextMarqueeView.m | 8 +++++++ .../SJScrollingTextMarqueeViewDefines.h | 1 + .../Utils/SJProgressSlider/SJProgressSlider.m | 22 +++++++++++++++---- .../SJEdgeControlLayer/SJEdgeControlLayer.m | 1 + 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.h b/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.h index c03a7ee48..526d41d93 100644 --- a/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.h +++ b/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.h @@ -16,5 +16,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, getter=isScrolling) BOOL scrolling; @property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; +@property (nonatomic, getter=isCentered) BOOL centered; @end NS_ASSUME_NONNULL_END diff --git a/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m b/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m index 2854833cb..f97dff3d9 100644 --- a/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m +++ b/SJVideoPlayer/Common/Implements/SJScrollingTextMarqueeView.m @@ -151,6 +151,10 @@ - (void)_reset { - (void)_prepareForAnimation { [self _setRightFadeMask]; + if ( _centered ) { + _leftLabel.sj_x = 0; + } + _rightLabel.hidden = NO; _rightLabel.attributedText = _leftLabel.attributedText; _rightLabel.sj_x = _leftLabel.sj_w + _margin; @@ -163,6 +167,10 @@ - (void)_prepareForNormalState { [self _removeFadeMasks]; _rightLabel.hidden = YES; + + if ( _centered ) { + _leftLabel.sj_x = self.sj_w * 0.5 - _leftLabel.sj_w * 0.5; + } } - (void)_startAnimationIfNeededAfterDelay:(NSTimeInterval)seconds { diff --git a/SJVideoPlayer/Common/Interfaces/SJScrollingTextMarqueeViewDefines.h b/SJVideoPlayer/Common/Interfaces/SJScrollingTextMarqueeViewDefines.h index d53b665bc..2b89e8e7b 100644 --- a/SJVideoPlayer/Common/Interfaces/SJScrollingTextMarqueeViewDefines.h +++ b/SJVideoPlayer/Common/Interfaces/SJScrollingTextMarqueeViewDefines.h @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, getter=isScrolling) BOOL scrolling; @property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; ///< default value is YES +@property (nonatomic, getter=isCentered) BOOL centered; ///< default value is NO. 标题太短无法滚动时, 是否居中显示 @end NS_ASSUME_NONNULL_END diff --git a/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m b/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m index 3743238f8..6beccc06b 100644 --- a/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m +++ b/SJVideoPlayer/Common/Utils/SJProgressSlider/SJProgressSlider.m @@ -189,10 +189,10 @@ - (void)setValue:(CGFloat)value_new animated:(BOOL)animated { CGFloat value_old = _value; if ( value_new < _minValue ) value_new = _minValue; else if ( value_new > _maxValue ) value_new = _maxValue; - if ( _showsStopNode ) { - CGFloat stop = _stopNodeLocation * _maxValue; - if ( value_new > stop ) value_new = stop; - } +// if ( _showsStopNode ) { +// CGFloat stop = _stopNodeLocation * _maxValue; +// if ( value_new > stop ) value_new = stop; +// } _value = value_new; if ( animated ) { @@ -212,6 +212,20 @@ - (void)setValue:(CGFloat)value_new animated:(BOOL)animated { } } +- (void)setMinValue:(CGFloat)minValue { + if ( minValue != _minValue ) { + _minValue = minValue; + [self _needUpdateContainerLayout]; + } +} + +- (void)setMaxValue:(CGFloat)maxValue { + if ( maxValue != _maxValue ) { + _maxValue = maxValue; + [self _needUpdateContainerLayout]; + } +} + /// add 此次增加的值 - (CGFloat)_calculateAnimaDuration:(CGFloat)add { add = ABS(add); diff --git a/SJVideoPlayer/ControlLayers/SJEdgeControlLayer/SJEdgeControlLayer.m b/SJVideoPlayer/ControlLayers/SJEdgeControlLayer/SJEdgeControlLayer.m index bf6a59bde..272881525 100644 --- a/SJVideoPlayer/ControlLayers/SJEdgeControlLayer/SJEdgeControlLayer.m +++ b/SJVideoPlayer/ControlLayers/SJEdgeControlLayer/SJEdgeControlLayer.m @@ -264,6 +264,7 @@ - (void)videoPlayerPlaybackStatusDidChange:(__kindof SJBaseVideoPlayer *)videoPl [self _showOrHiddenLoadingView]; [self _updateContentForBottomCurrentTimeItemIfNeeded]; [self _updateContentForBottomDurationItemIfNeeded]; + [self _updateContentForBottomProgressIndicatorIfNeeded]; } - (void)videoPlayer:(__kindof SJBaseVideoPlayer *)videoPlayer pictureInPictureStatusDidChange:(SJPictureInPictureStatus)status API_AVAILABLE(ios(14.0)) {