fix(player): suppress volume indicator during audio duck events (#1899)

When using AAudio output on Android, the system notifies the app to
manually handle ducking instead of silently lowering volume itself.
This caused the in-app volume indicator to pop up on every notification.

Pass showIndicator: false for duck begin/end calls so volume is adjusted
silently, consistent with other audio output modes.
This commit is contained in:
Starfallen
2026-04-24 12:36:50 +08:00
committed by GitHub
parent 73484f1f72
commit 91f00173bb
2 changed files with 11 additions and 4 deletions

View File

@@ -507,8 +507,11 @@ class PlPlayerController with BlockConfigMixin {
return _instance?.volume.value;
}
static Future<void>? setVolumeIfExists(double volumeNew) {
return _instance?.setVolume(volumeNew);
static Future<void>? setVolumeIfExists(
double volumeNew, {
bool showIndicator = true,
}) {
return _instance?.setVolume(volumeNew, showIndicator: showIndicator);
}
Box video = GStorage.video;
@@ -1255,7 +1258,7 @@ class PlPlayerController with BlockConfigMixin {
bool volumeInterceptEventStream = false;
static final double maxVolume = PlatformUtils.isDesktop ? 2.0 : 1.0;
Future<void> setVolume(double volume) async {
Future<void> setVolume(double volume, {bool showIndicator = true}) async {
if (this.volume.value != volume) {
this.volume.value = volume;
try {
@@ -1269,7 +1272,9 @@ class PlPlayerController with BlockConfigMixin {
if (kDebugMode) debugPrint(err.toString());
}
}
volumeIndicator.value = true;
if (showIndicator) {
volumeIndicator.value = true;
}
volumeInterceptEventStream = true;
volumeTimer?.cancel();
volumeTimer = Timer(const Duration(milliseconds: 200), () {