diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 6e012c6..6fcf2e6 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -92,36 +92,36 @@ static void repositionCreateTab(YTIGuideResponse *response) { %end // iOS 16 uYou crash fix - @level3tjg: https://github.com/qnblackcat/uYouPlus/pull/224 -%group iOS16 -%hook OBPrivacyLinkButton -%new -- (instancetype)initWithCaption:(NSString *)caption - buttonText:(NSString *)buttonText - image:(UIImage *)image - imageSize:(CGSize)imageSize - useLargeIcon:(BOOL)useLargeIcon { - return [self initWithCaption:caption - buttonText:buttonText - image:image - imageSize:imageSize - useLargeIcon:useLargeIcon - displayLanguage:[NSLocale currentLocale].languageCode]; -} -%end -%end +// %group iOS16 +// %hook OBPrivacyLinkButton +// %new +// - (instancetype)initWithCaption:(NSString *)caption +// buttonText:(NSString *)buttonText +// image:(UIImage *)image +// imageSize:(CGSize)imageSize +// useLargeIcon:(BOOL)useLargeIcon { +// return [self initWithCaption:caption +// buttonText:buttonText +// image:image +// imageSize:imageSize +// useLargeIcon:useLargeIcon +// displayLanguage:[NSLocale currentLocale].languageCode]; +// } +// %end +// %end // Fix uYou playback speed crashes YT v18.49.3+, see https://github.com/iCrazeiOS/uYouCrashFix -%hook YTPlayerViewController -%new --(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 { - return [[self activeVideo] playbackRate]; -} +// %hook YTPlayerViewController +// %new +// -(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 { +// return [[self activeVideo] playbackRate]; +// } -%new --(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 { - [[self activeVideo] setPlaybackRate:arg2]; -} -%end +// %new +// -(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 { +// [[self activeVideo] setPlaybackRate:arg2]; +// } +// %end // Fix streched artwork in uYou's player view - https://github.com/MiRO92/uYou-for-YouTube/issues/287 %hook ArtworkImageView @@ -146,8 +146,17 @@ static void repositionCreateTab(YTIGuideResponse *response) { %end // Fix uYou's appearance not updating if the app is backgrounded -DownloadsPagerVC *downloadsPagerVC; -NSUInteger selectedTabIndex; +static DownloadsPagerVC *downloadsPagerVC; +static NSUInteger selectedTabIndex; +%hook DownloadsPagerVC +- (id)init { + downloadsPagerVC = %orig; + return downloadsPagerVC; +} +- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 { + %orig; selectedTabIndex = arg1; +} +%end static void refreshUYouAppearance() { if (!downloadsPagerVC) return; // View pager @@ -186,31 +195,27 @@ static void refreshUYouAppearance() { } } } -%hook DownloadsPagerVC -- (instancetype)init { - downloadsPagerVC = %orig; - return downloadsPagerVC; -} -- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 { - %orig; selectedTabIndex = arg1; -} -%end %hook UIViewController - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { %orig; - refreshUYouAppearance(); + dispatch_async(dispatch_get_main_queue(), ^{ + refreshUYouAppearance(); + }); } %end // Prevent uYou's playback from colliding with YouTube's -BOOL isYTPlaybackActive = NO; -%hook HAMPlayerInternal -- (void)play { %orig; isYTPlaybackActive = YES; } -- (void)terminate { %orig; isYTPlaybackActive = NO; } +%hook PlayerVC +- (void)close { + %orig; + [[%c(PlayerManager) sharedInstance] setSource:nil]; +} %end -%hook PlayerManager +%hook HAMPlayerInternal - (void)play { - if (isYTPlaybackActive) return; + dispatch_async(dispatch_get_main_queue(), ^{ + [[%c(PlayerManager) sharedInstance] pause]; + }); %orig; } %end @@ -223,9 +228,9 @@ BOOL isYTPlaybackActive = NO; %ctor { %init; - if (@available(iOS 16, *)) { - %init(iOS16); - } + // if (@available(iOS 16, *)) { + // %init(iOS16); + // } // Disable broken options