From 268568b106fb55d96218cf2c9ef16646f4ec8d76 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:46:29 -0700 Subject: [PATCH] Improve audio smoothness visuals --- YTLitePlus.xm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 8cf80d6..125d30a 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -730,6 +730,11 @@ BOOL isTabSelected = NO; float volumeSensitivityFactor = 3.0; float newVolume = initialVolume + ((translationX / 1000.0) * sensitivityFactor * volumeSensitivityFactor); newVolume = fmaxf(fminf(newVolume, 1.0), 0.0); + // Improve smoothness - ignore if the volume is within 0.01 of the current volume + CGFloat currentVolume = [[AVAudioSession sharedInstance] outputVolume]; + if (fabs(newVolume - currentVolume) < 0.01 && currentVolume > 0.01 && currentVolume < 0.99) { + return; + } // https://stackoverflow.com/questions/50737943/how-to-change-volume-programmatically-on-ios-11-4 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{