mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
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:
@@ -507,8 +507,11 @@ class PlPlayerController with BlockConfigMixin {
|
|||||||
return _instance?.volume.value;
|
return _instance?.volume.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void>? setVolumeIfExists(double volumeNew) {
|
static Future<void>? setVolumeIfExists(
|
||||||
return _instance?.setVolume(volumeNew);
|
double volumeNew, {
|
||||||
|
bool showIndicator = true,
|
||||||
|
}) {
|
||||||
|
return _instance?.setVolume(volumeNew, showIndicator: showIndicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
Box video = GStorage.video;
|
Box video = GStorage.video;
|
||||||
@@ -1255,7 +1258,7 @@ class PlPlayerController with BlockConfigMixin {
|
|||||||
bool volumeInterceptEventStream = false;
|
bool volumeInterceptEventStream = false;
|
||||||
|
|
||||||
static final double maxVolume = PlatformUtils.isDesktop ? 2.0 : 1.0;
|
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) {
|
if (this.volume.value != volume) {
|
||||||
this.volume.value = volume;
|
this.volume.value = volume;
|
||||||
try {
|
try {
|
||||||
@@ -1269,7 +1272,9 @@ class PlPlayerController with BlockConfigMixin {
|
|||||||
if (kDebugMode) debugPrint(err.toString());
|
if (kDebugMode) debugPrint(err.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
volumeIndicator.value = true;
|
if (showIndicator) {
|
||||||
|
volumeIndicator.value = true;
|
||||||
|
}
|
||||||
volumeInterceptEventStream = true;
|
volumeInterceptEventStream = true;
|
||||||
volumeTimer?.cancel();
|
volumeTimer?.cancel();
|
||||||
volumeTimer = Timer(const Duration(milliseconds: 200), () {
|
volumeTimer = Timer(const Duration(milliseconds: 200), () {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class AudioSessionHandler {
|
|||||||
case AudioInterruptionType.duck:
|
case AudioInterruptionType.duck:
|
||||||
PlPlayerController.setVolumeIfExists(
|
PlPlayerController.setVolumeIfExists(
|
||||||
(PlPlayerController.getVolumeIfExists() ?? 0) * 0.5,
|
(PlPlayerController.getVolumeIfExists() ?? 0) * 0.5,
|
||||||
|
showIndicator: false,
|
||||||
);
|
);
|
||||||
// player.setVolume(player.volume.value * 0.5);
|
// player.setVolume(player.volume.value * 0.5);
|
||||||
break;
|
break;
|
||||||
@@ -47,6 +48,7 @@ class AudioSessionHandler {
|
|||||||
case AudioInterruptionType.duck:
|
case AudioInterruptionType.duck:
|
||||||
PlPlayerController.setVolumeIfExists(
|
PlPlayerController.setVolumeIfExists(
|
||||||
(PlPlayerController.getVolumeIfExists() ?? 0) * 2,
|
(PlPlayerController.getVolumeIfExists() ?? 0) * 2,
|
||||||
|
showIndicator: false,
|
||||||
);
|
);
|
||||||
// player.setVolume(player.volume.value * 2);
|
// player.setVolume(player.volume.value * 2);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user