From 2fda2189cb1547286698ca61644228ebe6827448 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Wed, 8 May 2024 19:40:03 -0700 Subject: [PATCH 1/2] Fix Remaining Time --- Sources/uYouPlus.h | 3 +++ Sources/uYouPlus.xm | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index d2a3031..bbd180c 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -55,6 +55,9 @@ #define LOWCONTRASTMODE_CUTOFF_VERSION @"17.38.10" // LowContrastMode (v17.33.2-17.38.10) // Always show remaining time in video player - @bhackel +@interface YTPlayerBarController : NSObject +@property(nonatomic, strong) YTInlinePlayerBarContainerView *playerBar; +@end @interface YTInlinePlayerBarContainerView (uYouEnhanced) @property(nonatomic, assign) BOOL shouldDisplayTimeRemaining; @end diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index aa3774c..c664731 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -971,14 +971,18 @@ NSData *cellDividerData; %end // Always use remaining time in the video player - @bhackel -%hook YTInlinePlayerBarContainerView -// Modify constructor to enable the feature when it is done -- (instancetype)init { - YTInlinePlayerBarContainerView *playerBar = (YTInlinePlayerBarContainerView *)%orig; - if (playerBar && IS_ENABLED(@"alwaysShowRemainingTime_enabled")) { - playerBar.shouldDisplayTimeRemaining = YES; +%hook YTPlayerBarController +// When a new video is played, enable time remaining flag +- (void)setActiveSingleVideo:(id)arg1 { + %orig; + if (IS_ENABLED(@"alwaysShowRemainingTime_enabled")) { + // Get the player bar view + YTInlinePlayerBarContainerView *playerBar = self.playerBar; + if (playerBar) { + // Enable the time remaining flag + playerBar.shouldDisplayTimeRemaining = YES; + } } - return playerBar; } %end From 22b61ce7df78b5566116865d71e93a6a11809ca1 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Wed, 8 May 2024 20:05:02 -0700 Subject: [PATCH 2/2] Add disable toggle for time remaining --- Sources/uYouPlus.xm | 16 ++++++++++++++++ Sources/uYouPlusSettings.xm | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index c664731..50c7f93 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -986,6 +986,22 @@ NSData *cellDividerData; } %end +// Disable toggle time remaining - @bhackel +%hook YTInlinePlayerBarContainerView +- (void)setShouldDisplayTimeRemaining:(BOOL)arg1 { + if (IS_ENABLED(@"disableRemainingTime_enabled")) { + // Set true if alwaysShowRemainingTime + if (IS_ENABLED(@"alwaysShowRemainingTime_enabled")) { + %orig(YES); + } else { + %orig(NO); + } + return; + } + %orig; +} +%end + // Hide previous and next buttons in all videos - @bhackel %group gHidePreviousAndNextButton %hook YTColdConfig diff --git a/Sources/uYouPlusSettings.xm b/Sources/uYouPlusSettings.xm index 21e0958..7e96f6b 100644 --- a/Sources/uYouPlusSettings.xm +++ b/Sources/uYouPlusSettings.xm @@ -319,7 +319,8 @@ extern NSBundle *uYouPlusBundle(); SWITCH_ITEM2(LOC(@"STOCK_VOLUME_HUD"), LOC(@"STOCK_VOLUME_HUD_DESC"), @"stockVolumeHUD_enabled"); SWITCH_ITEM2(LOC(@"Disable pull-to-fullscreen gesture"), LOC(@"Disable the drag gesture to enter vertical fullscreen. Only applies to landscape videos."), @"disablePullToFull_enabled"); SWITCH_ITEM(LOC(@"Disable Double tap to skip chapter"), LOC(@"Disable the 2-finger double tap gesture that skips forward/backward by a chapter"), @"disableChapterSkip_enabled"); - SWITCH_ITEM2(LOC(@"Always use remaining time"), LOC(@"Change the default to show time remaining in the player bar"), @"alwaysShowRemainingTime_enabled"); + SWITCH_ITEM(LOC(@"Always use remaining time"), LOC(@"Change the default to show time remaining in the player bar"), @"alwaysShowRemainingTime_enabled"); + SWITCH_ITEM(LOC(@"Disable toggle time remaining"), LOC(@"Disables changing time elapsed to time remaining. Use with other setting to always show remaining time."), @"disableRemainingTime_enabled"); # pragma mark - Video controls overlay options SECTION_HEADER(LOC(@"VIDEO_PLAYER_OPTIONS"));