diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index 6a162b3..f91c692 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -51,6 +51,19 @@ @property (nonatomic, strong) UIView *_scrimOverlay; @end +// YTTapToSeek - https://github.com/bhackel/YTTapToSeek +@interface YTInlinePlayerBarContainerView : UIView +@property (nonatomic, weak, readwrite) id delegate; +- (void)didPressScrubber:(id)arg1; +- (CGFloat)scrubRangeForScrubX:(CGFloat)arg1; +@end +@interface YTMainAppVideoPlayerOverlayViewController : UIViewController +- (CGFloat)totalTime; +@end +@interface YTPlayerViewController : UIViewController +- (void)seekToTime:(double)time; +@end + // uYouPlus @interface YTHeaderLogoController : UIView @property(readonly, nonatomic) long long pageStyle; diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index 048285d..1f803dc 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -491,6 +491,28 @@ static NSString *accessGroupID() { } %end +// YTTapToSeek - https://github.com/bhackel/YTTapToSeek +%group YTTTS_Tweak + %hook YTInlinePlayerBarContainerView + - (void)didPressScrubber:(id)arg1 { + %orig; + // Get access to the seekToTime method + YTMainAppVideoPlayerOverlayViewController *mainAppController = [self.delegate valueForKey:@"_delegate"]; + YTPlayerViewController *playerViewController = [mainAppController valueForKey:@"parentViewController"]; + // Get the X position of this tap from arg1 + UIGestureRecognizer *gestureRecognizer = (UIGestureRecognizer *)arg1; + CGPoint location = [gestureRecognizer locationInView:self]; + CGFloat x = location.x; + // Get the associated proportion of time using scrubRangeForScrubX + double timestampFraction = [self scrubRangeForScrubX:x]; + // Get the timestamp from the fraction + double timestamp = [mainAppController totalTime] * timestampFraction; + // Jump to the timestamp + [playerViewController seekToTime:timestamp]; + } + %end +%end + # pragma mark - Hide Notification Button && SponsorBlock Button && uYouPlus Button %hook YTRightNavigationButtons - (void)layoutSubviews { @@ -1296,6 +1318,9 @@ static BOOL findCell(ASNodeController *nodeController, NSArray *ide if (IS_ENABLED(@"disableLiveChatSection_enabled")) { %init(gDisableLiveChatSection); } + if (IS_ENABLED(@"YTTapToSeek_enabled")) { + %init(YTTTS_Tweak); + } // YTNoModernUI - @arichorn BOOL ytNoModernUIEnabled = IS_ENABLED(@"ytNoModernUI_enabled"); diff --git a/Sources/uYouPlusSettings.xm b/Sources/uYouPlusSettings.xm index 5d8076b..14ea3d0 100644 --- a/Sources/uYouPlusSettings.xm +++ b/Sources/uYouPlusSettings.xm @@ -202,6 +202,7 @@ extern NSBundle *uYouPlusBundle(); SWITCH_ITEM2(LOC(@"Enable Portrait Fullscreen (iPhone-Exclusive)"), LOC(@"Enables Portrait Fullscreen on the YouTube App. App restart is required."), @"portraitFullscreen_enabled"); SWITCH_ITEM2(LOC(@"SLIDE_TO_SEEK"), LOC(@"SLIDE_TO_SEEK_DESC"), @"slideToSeek_enabled"); + SWITCH_ITEM2(LOC(@"Enable Tap To Seek"), LOC(@"Jump to anywhere in a video by single-tapping the seek bar"), @"YTTapToSeek_enabled"); SWITCH_ITEM(LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK"), LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK_DESC"), @"doubleTapToSeek_disabled"); SWITCH_ITEM2(LOC(@"SNAP_TO_CHAPTER"), LOC(@"SNAP_TO_CHAPTER_DESC"), @"snapToChapter_enabled"); SWITCH_ITEM2(LOC(@"PINCH_TO_ZOOM"), LOC(@"PINCH_TO_ZOOM_DESC"), @"pinchToZoom_enabled");