mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-23 12:10:33 +08:00
set system brightness
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -98,6 +98,7 @@ class PlPlayerController {
|
||||
final RxDouble _currentVolume = RxDouble(
|
||||
Utils.isDesktop ? Pref.desktopVolume : 1.0,
|
||||
);
|
||||
final setSystemBrightness = Pref.setSystemBrightness;
|
||||
final RxDouble _currentBrightness = (-1.0).obs;
|
||||
|
||||
final RxBool _showControls = false.obs;
|
||||
|
||||
@@ -204,14 +204,22 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
try {
|
||||
_brightnessValue.value =
|
||||
await ScreenBrightnessPlatform.instance.application;
|
||||
_listener = ScreenBrightnessPlatform
|
||||
.instance
|
||||
.onApplicationScreenBrightnessChanged
|
||||
.listen((double value) {
|
||||
if (mounted) {
|
||||
_brightnessValue.value = value;
|
||||
}
|
||||
});
|
||||
|
||||
void listener(double value) {
|
||||
if (mounted) {
|
||||
_brightnessValue.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
_listener = Platform.isIOS || plPlayerController.setSystemBrightness
|
||||
? ScreenBrightnessPlatform
|
||||
.instance
|
||||
.onSystemScreenBrightnessChanged
|
||||
.listen(listener)
|
||||
: ScreenBrightnessPlatform
|
||||
.instance
|
||||
.onApplicationScreenBrightnessChanged
|
||||
.listen(listener);
|
||||
} catch (_) {}
|
||||
});
|
||||
}
|
||||
@@ -264,9 +272,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
|
||||
Future<void> setBrightness(double value) async {
|
||||
try {
|
||||
await ScreenBrightnessPlatform.instance.setApplicationScreenBrightness(
|
||||
value,
|
||||
);
|
||||
if (Platform.isIOS || plPlayerController.setSystemBrightness) {
|
||||
await ScreenBrightnessPlatform.instance.setSystemScreenBrightness(
|
||||
value,
|
||||
);
|
||||
} else {
|
||||
await ScreenBrightnessPlatform.instance.setApplicationScreenBrightness(
|
||||
value,
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
_brightnessIndicator.value = true;
|
||||
_brightnessTimer?.cancel();
|
||||
|
||||
Reference in New Issue
Block a user