Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: Switch to video can be hidden from the player, under either look
My-Name-Is-Jeff3b390896e602
diff --git a/tweak/Sources/App/Pages.m b/tweak/Sources/App/Pages.mindex 77e22e0f..8f0cacd6 100644--- a/tweak/Sources/App/Pages.m+++ b/tweak/Sources/App/Pages.m@@ -131,6 +131,10 @@ UIViewController *SGPlayerSettingsPage(void) {[pages addObject:SGWithSymbol(SGPageRow(@"Lock screen widget", ^UIViewController *{ return SGLockScreenWidgetPage(); }), @"lock")];[sections addObject:SGSection(nil, pages)];if (native) [sections addObjectsFromArray:SGNativePlayerScreenSections()];+ // Switch to video is the same chip of Spotify's player under either look.+ [sections addObject:SGSection(native ? nil : @"Hide on the player", @[+ SGHideRow(@"Switch to video", @"The chip over the title of a song with a music video", SGKeyHideVideoSwitch),+ ])];// Vibrations hook Spotify's own controls and its audio, so they answer under either look.[sections addObjectsFromArray:SGVibrationsSections()];diff --git a/tweak/Sources/Shared/Player/PlayerSettings.h b/tweak/Sources/Shared/Player/PlayerSettings.hindex 29ac7011..db867f0d 100644--- a/tweak/Sources/Shared/Player/PlayerSettings.h+++ b/tweak/Sources/Shared/Player/PlayerSettings.h@@ -2,3 +2,6 @@#import <UIKit/UIKit.h>UIViewController *SGLockScreenWidgetPage(void);++// Switch to video hidden from the player under either look (VideoSwitch.x), off until switched on.+#define SGKeyHideVideoSwitch @"spotifyglass.hide.videoSwitch"diff --git a/tweak/Sources/Shared/Player/VideoSwitch.x b/tweak/Sources/Shared/Player/VideoSwitch.xnew file mode 100644index 00000000..7852be56--- /dev/null+++ b/tweak/Sources/Shared/Player/VideoSwitch.x@@ -0,0 +1,45 @@+// Switch to video hidden from the player, under either look (SGKeyHideVideoSwitch, off until switched on).+//+// The switch is the chip Spotify puts over the track's title for a song with a music video, Switch to+// video and, once switched, Switch to audio. Its accessibility identifier is nowplaying-npv-musicvideos-switch:+// in 9.1.78's strings it sits between NowPlaying_ElementsKit's AudioVideoSwitchButtonAdapter and the+// sNowPlayingMusicVideosSwitchToVideo and ...SwitchToAudio strings, and no recorded tree shows it yet. The+// chips are FloatingElementsUnit's (Redesigned/Player/PlayerLyrics.x), a unit of Spotify's player that both+// looks keep, so its pass looks for it there. It goes by alpha, not hidden, since it may sit in one of+// Spotify's stacks (AGENTS.md), and takes no touches and says nothing to VoiceOver.+#import "Core/SGCore.h"+#import "PlayerSettings.h"++static NSString *const kSwitchIdentifier = @"nowplaying-npv-musicvideos-switch";++static UIView *switchIn(UIView *root, int depth) {+ if ([root.accessibilityIdentifier isEqualToString:kSwitchIdentifier]) return root;+ if (depth > 10) return nil;+ for (UIView *child in root.subviews) {+ UIView *found = switchIn(child, depth + 1);+ if (found) return found;+ }+ return nil;+}++%hook _TtC20NowPlaying_ModesImpl20FloatingElementsUnit+- (void)viewDidLayoutSubviews {+ %orig;+ UIView *videoSwitch = switchIn(((UIViewController *)self).viewIfLoaded, 0);+ if (!videoSwitch) return;+ static BOOL logged;+ if (!logged) {+ logged = YES;+ SGLog(@"player: Switch to video hidden, %@ %@", NSStringFromClass(videoSwitch.class), NSStringFromCGRect(videoSwitch.frame));+ }+ videoSwitch.alpha = 0;+ videoSwitch.userInteractionEnabled = NO;+ videoSwitch.accessibilityElementsHidden = YES;+}+%end++%ctor {+ if (!SGHidden(SGKeyHideVideoSwitch)) return;+ %init;+ SGRequireClasses(@[@"_TtC20NowPlaying_ModesImpl20FloatingElementsUnit"]);+}