Add YTTapToSeek

This commit is contained in:
Bryce Hackel 2024-03-17 19:11:28 -07:00
parent 5cd7dbffef
commit 3176101d5d
No known key found for this signature in database
GPG key ID: F031960F08455E88
3 changed files with 39 additions and 0 deletions

View file

@ -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;

View file

@ -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 <NSString *> *ide
if (IS_ENABLED(@"disableLiveChatSection_enabled")) {
%init(gDisableLiveChatSection);
}
if (IS_ENABLED(@"YTTapToSeek_enabled")) {
%init(YTTTS_Tweak);
}
// YTNoModernUI - @arichorn
BOOL ytNoModernUIEnabled = IS_ENABLED(@"ytNoModernUI_enabled");

View file

@ -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");