diff --git a/Source/Settings.xm b/Source/Settings.xm index 301fdc5..36ff505 100644 --- a/Source/Settings.xm +++ b/Source/Settings.xm @@ -18,7 +18,7 @@ static int colorContrastMode() { static int appVersionSpoofer() { return [[NSUserDefaults standardUserDefaults] integerForKey:@"versionSpoofer"]; } -static const NSInteger YTLitePlusSection = 500; +static const NSInteger YTLitePlusSection = 788; @interface YTSettingsSectionItemManager (YTLitePlus) - (void)updateYTLitePlusSectionWithEntry:(id)entry; @@ -64,35 +64,6 @@ extern NSBundle *YTLitePlusBundle(); }]; [sectionItems addObject:main]; -# pragma mark - VideoPlayer - YTSettingsSectionItem *videoPlayerGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"VIDEO_PLAYER_OPTIONS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { - NSArray *rows = @[ - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_MINIPLAYER") - titleDescription:LOC(@"YT_MINIPLAYER_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"ytMiniPlayer_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytMiniPlayer_enabled"]; - return YES; - } - settingItemId:0], - - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"STOCK_VOLUME_HUD") - titleDescription:LOC(@"STOCK_VOLUME_HUD_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"stockVolumeHUD_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"stockVolumeHUD_enabled"]; - return YES; - } - settingItemId:0] - ]; - YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"VIDEO_PLAYER_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; - [settingsViewController pushViewController:picker]; - return YES; - }]; - [sectionItems addObject:videoPlayerGroup]; - # pragma mark - Video Controls Overlay Options YTSettingsSectionItem *videoControlOverlayGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"VIDEO_CONTROLS_OVERLAY_OPTIONS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { NSArray *rows = @[ @@ -430,6 +401,16 @@ extern NSBundle *YTLitePlusBundle(); } settingItemId:0], + [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"STOCK_VOLUME_HUD") + titleDescription:LOC(@"STOCK_VOLUME_HUD_DESC") + accessibilityIdentifier:nil + switchOn:IsEnabled(@"stockVolumeHUD_enabled") + switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"stockVolumeHUD_enabled"]; + return YES; + } + settingItemId:0], + [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CAST_BUTTON") titleDescription:LOC(@"HIDE_CAST_BUTTON_DESC") accessibilityIdentifier:nil @@ -459,7 +440,17 @@ extern NSBundle *YTLitePlusBundle(); return YES; } settingItemId:0], - + + [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_SPEED") + titleDescription:LOC(@"YT_SPEED_DESC") + accessibilityIdentifier:nil + switchOn:IsEnabled(@"ytSpeed_enabled") + switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytSpeed_enabled"]; + return YES; + } + settingItemId:0], + [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_FLEX") titleDescription:LOC(@"ENABLE_FLEX_DESC") accessibilityIdentifier:nil diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 8cf853d..755c8ef 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -270,6 +270,55 @@ static BOOL IsEnabled(NSString *key) { %end %end +// YTSpeed - https://github.com/Lyvendia/YTSpeed (Only works on YouTube v16.05.7-v18.18.2) +%group gYTSpeed +%hook YTVarispeedSwitchController +- (id)init { + id result = %orig; + + const int size = 17; + float speeds[] = {0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 5.0}; + id varispeedSwitchControllerOptions[size]; + + for (int i = 0; i < size; ++i) { + id title = [NSString stringWithFormat:@"%.2fx", speeds[i]]; + varispeedSwitchControllerOptions[i] = [[%c(YTVarispeedSwitchControllerOption) alloc] initWithTitle:title rate:speeds[i]]; + } + + NSUInteger count = sizeof(varispeedSwitchControllerOptions) / sizeof(id); + NSArray *varispeedArray = [NSArray arrayWithObjects:varispeedSwitchControllerOptions count:count]; + MSHookIvar(self, "_options") = varispeedArray; + + return result; +} +%end + +%hook MLHAMQueuePlayer +- (void)setRate:(float)rate { + MSHookIvar(self, "_rate") = rate; + MSHookIvar(self, "_preferredRate") = rate; + + id player = MSHookIvar(self, "_player"); + [player setRate: rate]; + + id stickySettings = MSHookIvar(self, "_stickySettings"); + [stickySettings setRate: rate]; + + [self.playerEventCenter broadcastRateChange: rate]; + + YTSingleVideoController *singleVideoController = self.delegate; + [singleVideoController playerRateDidChange: rate]; +} +%end + +%hook YTPlayerViewController +%property (nonatomic, assign) float playbackRate; +- (void)singleVideo:(id)video playbackRateDidChange:(float)rate { + %orig; +} +%end +%end + // YTStockVolumeHUD - https://github.com/lilacvibes/YTStockVolumeHUD %group gStockVolumeHUD %hook YTVolumeBarView @@ -366,6 +415,9 @@ static BOOL IsEnabled(NSString *key) { if (IsEnabled(@"ytNoModernUI_enabled")) { %init(gYTNoModernUI); } + if (IsEnabled(@"ytSpeed_enabled")) { + %init(gYTSpeed); + } if (IsEnabled(@"stockVolumeHUD_enabled")) { %init(gStockVolumeHUD); }