Skip to content

Commit

Permalink
修复抽离手势出现的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Dec 12, 2017
1 parent 42ae633 commit d1bd8f7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion SJVideoPlayer/GestureControl/SJPlayerGestureControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ typedef NS_ENUM(NSUInteger, SJPanLocation) {
- (instancetype)initWithTargetView:(__weak UIView *)view;

@property (nonatomic, copy, readwrite, nullable) BOOL(^triggerCondition)(SJPlayerGestureControl *control, UIGestureRecognizer *gesture);
@property (nonatomic, copy, readwrite, nullable) BOOL(^fadeArea)(CGPoint point);

@property (nonatomic, copy, readwrite, nullable) void(^singleTapped)(SJPlayerGestureControl *control);
@property (nonatomic, copy, readwrite, nullable) void(^doubleTapped)(SJPlayerGestureControl *control);
Expand All @@ -38,3 +37,4 @@ typedef NS_ENUM(NSUInteger, SJPanLocation) {
@end

NS_ASSUME_NONNULL_END

3 changes: 2 additions & 1 deletion SJVideoPlayer/GestureControl/SJPlayerGestureControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ - (void)_addGestureToControlView {
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ( _fadeArea ) return !_fadeArea([gestureRecognizer locationInView:gestureRecognizer.view]);
if ( _triggerCondition ) return _triggerCondition(self, gestureRecognizer);
return YES;
}
Expand Down Expand Up @@ -127,3 +126,5 @@ - (void)handlePan:(UIPanGestureRecognizer *)pan {
}

@end


46 changes: 21 additions & 25 deletions SJVideoPlayer/Player/SJVideoPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ - (BOOL)isLockedScrren {
}

- (void)setHideControl:(BOOL)hideControl {
// if ( self.isHiddenControl == hideControl ) return;
// if ( self.isHiddenControl == hideControl ) return;
objc_setAssociatedObject(self, @selector(isHiddenControl), @(hideControl), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self.timerControl reset];
if ( hideControl ) [self _hideControlState];
Expand Down Expand Up @@ -293,7 +293,7 @@ - (void)_unlockScreenState {
}

- (void)_hideControlState {

// show
_sjShowViews(@[self.controlView.bottomProgressSlider]);

Expand All @@ -303,7 +303,7 @@ - (void)_hideControlState {
// transform hidden
self.controlView.topControlView.transform = CGAffineTransformMakeTranslation(0, -SJControlTopH);
self.controlView.bottomControlView.transform = CGAffineTransformMakeTranslation(0, SJControlBottomH);

if ( self.orentation.fullScreen ) {
if ( self.isLockedScrren ) self.hiddenLeftControlView = NO;
else self.hiddenLeftControlView = YES;
Expand Down Expand Up @@ -382,7 +382,7 @@ - (instancetype)init {
if ( error ) {
_sjErrorLog([NSString stringWithFormat:@"%@", error.userInfo]);
}

[self view];
[self orentation];
[self volBrig];
Expand Down Expand Up @@ -530,7 +530,7 @@ - (SJVideoPlayerMoreSettingSecondaryView *)moreSecondarySettingView {
_moreSettingFooterViewModel.initialPlayerRateValue = ^float{
__strong typeof(_self) self = _self;
if ( !self ) return 0;
return self.asset.player.rate;
return self.asset.player.rate;
};

_moreSettingView.footerViewModel = _moreSettingFooterViewModel;
Expand Down Expand Up @@ -647,11 +647,11 @@ - (SJVideoPlayerRegistrar *)registrar {
if ( !self.userClickedPause ) [self play];
};

// _registrar.categoryChange = ^(SJVideoPlayerRegistrar * _Nonnull registrar) {
// __strong typeof(_self) self = _self;
// if ( !self ) return;
//
// };
// _registrar.categoryChange = ^(SJVideoPlayerRegistrar * _Nonnull registrar) {
// __strong typeof(_self) self = _self;
// if ( !self ) return;
//
// };

return _registrar;
}
Expand All @@ -677,29 +677,24 @@ - (SJVolBrigControl *)volBrig {
- (void)gesturesHandleWithTargetView:(UIView *)targetView {

_gestureControl = [[SJPlayerGestureControl alloc] initWithTargetView:targetView];

__weak typeof(self) _self = self;
_gestureControl.triggerCondition = ^BOOL(SJPlayerGestureControl * _Nonnull control, UIGestureRecognizer *gesture) {
__strong typeof(_self) self = _self;
if ( !self ) return NO;
if ( self.isLockedScrren ) return NO;
CGPoint point = [gesture locationInView:gesture.view];
if ( CGRectContainsPoint(self.moreSettingView.frame, point) ||
CGRectContainsPoint(self.moreSecondarySettingView.frame, point) ||
CGRectContainsPoint(self.controlView.previewView.frame, point) ) {
return NO;
}
if ( [gesture isKindOfClass:[UIPanGestureRecognizer class]] &&
self.playOnCell &&
self.playOnCell &&
!self.orentation.fullScreen ) return NO;
else return YES;
};

_gestureControl.fadeArea = ^BOOL(CGPoint point) {
__strong typeof(_self) self = _self;
if ( !self ) return YES;
if ( CGRectContainsPoint(self.moreSettingView.frame, point) ||
CGRectContainsPoint(self.moreSecondarySettingView.frame, point) ||
CGRectContainsPoint(self.controlView.previewView.frame, point) ) {
return YES;
}
return NO;
};

_gestureControl.singleTapped = ^(SJPlayerGestureControl * _Nonnull control) {
__strong typeof(_self) self = _self;
if ( !self ) return;
Expand Down Expand Up @@ -1133,7 +1128,7 @@ - (void)setAsset:(SJVideoPlayerAssetCarrier *)asset {
break;
}
});

};

asset.playTimeChanged = ^(SJVideoPlayerAssetCarrier * _Nonnull asset, NSTimeInterval currentTime, NSTimeInterval duration) {
Expand Down Expand Up @@ -1390,7 +1385,7 @@ - (void)setDisableRotation:(BOOL)disableRotation {

- (BOOL)disableRotation {
return [objc_getAssociatedObject(self, _cmd) boolValue];
}
}

- (void)setVideoGravity:(AVLayerVideoGravity)videoGravity {
objc_setAssociatedObject(self, @selector(videoGravity), videoGravity, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
Expand Down Expand Up @@ -1530,3 +1525,4 @@ - (void)hiddenTitle {
}

@end

Binary file not shown.

0 comments on commit d1bd8f7

Please sign in to comment.