mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-20 10:52:07 +00:00
YTSpeed works with Latest Version.
These changes + headers were made by level3tjg! Please go and support for their hard work! They done an amazing job! 🎊
This commit is contained in:
parent
fd6a07a420
commit
19849087da
1 changed files with 33 additions and 21 deletions
54
uYouPlus.xm
54
uYouPlus.xm
|
|
@ -737,27 +737,46 @@ static void replaceTab(YTIGuideResponse *response) {
|
|||
// YTSpeed - https://github.com/Lyvendia/YTSpeed
|
||||
%group gYTSpeed
|
||||
%hook YTVarispeedSwitchController
|
||||
- (id)init {
|
||||
id result = %orig;
|
||||
- (instancetype)init {
|
||||
if ((self = %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];
|
||||
|
||||
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]];
|
||||
}
|
||||
|
||||
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<NSArray *>(self, "_options") = varispeedArray;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
%end
|
||||
|
||||
NSUInteger count = sizeof(varispeedSwitchControllerOptions) / sizeof(id);
|
||||
NSArray *varispeedArray = [NSArray arrayWithObjects:varispeedSwitchControllerOptions count:count];
|
||||
MSHookIvar<NSArray *>(self, "_options") = varispeedArray;
|
||||
|
||||
return result;
|
||||
%hook YTLocalPlaybackController
|
||||
- (instancetype)initWithParentResponder:(id)parentResponder overlayFactory:(id)overlayFactory playerView:(id)playerView playbackControllerDelegate:(id)playbackControllerDelegate viewportSizeProvider:(id)viewportSizeProvider shouldDelayAdsPlaybackCoordinatorCreation:(BOOL)shouldDelayAdsPlaybackCoordinatorCreation {
|
||||
float savedRate = [[NSUserDefaults standardUserDefaults] floatForKey:@"YoutubeSpeed_PlaybackRate"];
|
||||
if ((self = %orig)) {
|
||||
MSHookIvar<float>(self, "_restoredPlaybackRate") = savedRate == 0 ? DEFAULT_RATE : savedRate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)setPlaybackRate:(float)rate {
|
||||
%orig;
|
||||
[[NSUserDefaults standardUserDefaults] setFloat: rate forKey:@"YoutubeSpeed_PlaybackRate"];
|
||||
}
|
||||
%end
|
||||
|
||||
%hook MLHAMQueuePlayer
|
||||
- (instancetype)initWithStickySettings:(id)stickySettings playerViewProvider:(id)playerViewProvider {
|
||||
id result = %orig;
|
||||
float savedRate = [[NSUserDefaults standardUserDefaults] floatForKey:@"YoutubeSpeed_PlaybackRate"];
|
||||
[self setRate: savedRate == 0 ? DEFAULT_RATE : savedRate];
|
||||
return result;
|
||||
}
|
||||
- (void)setRate:(float)rate {
|
||||
MSHookIvar<float>(self, "_rate") = rate;
|
||||
MSHookIvar<float>(self, "_preferredRate") = rate;
|
||||
|
|
@ -773,13 +792,6 @@ static void replaceTab(YTIGuideResponse *response) {
|
|||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue