From 880603f7f464412699d86a609f1b9c779eb927c0 Mon Sep 17 00:00:00 2001 From: Foxster Date: Sun, 28 Jan 2024 09:53:08 -0800 Subject: [PATCH] Actually prevent uYou's playback from colliding with YouTube's --- Sources/uYouPlusPatches.h | 6 +++++- Sources/uYouPlusPatches.xm | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Sources/uYouPlusPatches.h b/Sources/uYouPlusPatches.h index 1efe8d2..e0e8e37 100644 --- a/Sources/uYouPlusPatches.h +++ b/Sources/uYouPlusPatches.h @@ -10,9 +10,13 @@ -(YTSingleVideoController *)activeVideo; @end -// Prevent uYou player bar from showing when not playing downloaded media @interface PlayerManager : NSObject +// Prevent uYou player bar from showing when not playing downloaded media - (float)progress; +// Prevent uYou's playback from colliding with YouTube's +- (void)setSource:(id)source; +- (void)pause; ++ (id)sharedInstance; @end // iOS 16 uYou crash fix - @level3tjg: https://github.com/qnblackcat/uYouPlus/pull/224 diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 3df68de..99ec0b1 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -173,14 +173,17 @@ static void 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