Skip to content

Commit

Permalink
Actually prevent uYou's playback from colliding with YouTube's
Browse files Browse the repository at this point in the history
  • Loading branch information
therealFoxster committed Jan 28, 2024
1 parent 61e55e1 commit 880603f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Sources/uYouPlusPatches.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions Sources/uYouPlusPatches.xm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 880603f

Please sign in to comment.