mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
set system brightness
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -210,4 +210,5 @@
|
||||
-->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||
</manifest>
|
||||
|
||||
@@ -143,7 +143,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
void dispose() {
|
||||
videoPlayerServiceHandler?.onVideoDetailDispose(heroTag);
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
if (Utils.isMobile) {
|
||||
if (Platform.isAndroid && !plPlayerController.setSystemBrightness) {
|
||||
ScreenBrightnessPlatform.instance.resetApplicationScreenBrightness();
|
||||
}
|
||||
PlPlayerController.setPlayCallBack(null);
|
||||
|
||||
@@ -82,6 +82,14 @@ List<SettingsModel> get playSettings => [
|
||||
setKey: SettingBoxKey.enableSlideVolumeBrightness,
|
||||
defaultVal: true,
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
const SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '调节系统亮度',
|
||||
leading: Icon(Icons.brightness_6_outlined),
|
||||
setKey: SettingBoxKey.setSystemBrightness,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '中间滑动进入/退出全屏',
|
||||
|
||||
@@ -110,6 +110,7 @@ class VideoDetailController extends GetxController
|
||||
|
||||
PlPlayerController plPlayerController = PlPlayerController.getInstance()
|
||||
..setCurrBrightness(-1.0);
|
||||
bool get setSystemBrightness => plPlayerController.setSystemBrightness;
|
||||
|
||||
late VideoItem firstVideo;
|
||||
late AudioItem firstAudio;
|
||||
|
||||
@@ -326,7 +326,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
);
|
||||
|
||||
if (!Get.previousRoute.startsWith('/video')) {
|
||||
if (Utils.isMobile) {
|
||||
if (Platform.isAndroid && !videoDetailController.setSystemBrightness) {
|
||||
ScreenBrightnessPlatform.instance.resetApplicationScreenBrightness();
|
||||
}
|
||||
PlPlayerController.setPlayCallBack(null);
|
||||
@@ -371,7 +371,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
|
||||
if (Utils.isMobile) {
|
||||
if (Platform.isAndroid && !videoDetailController.setSystemBrightness) {
|
||||
ScreenBrightnessPlatform.instance.resetApplicationScreenBrightness();
|
||||
}
|
||||
|
||||
@@ -418,7 +418,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
|
||||
introController.startTimer();
|
||||
|
||||
if (Utils.isMobile && mounted) {
|
||||
if (mounted &&
|
||||
Platform.isAndroid &&
|
||||
!videoDetailController.setSystemBrightness) {
|
||||
if (videoDetailController.brightness != null) {
|
||||
plPlayerController?.setCurrBrightness(
|
||||
videoDetailController.brightness!,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
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 {
|
||||
if (Platform.isIOS || plPlayerController.setSystemBrightness) {
|
||||
await ScreenBrightnessPlatform.instance.setSystemScreenBrightness(
|
||||
value,
|
||||
);
|
||||
} else {
|
||||
await ScreenBrightnessPlatform.instance.setApplicationScreenBrightness(
|
||||
value,
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
_brightnessIndicator.value = true;
|
||||
_brightnessTimer?.cancel();
|
||||
|
||||
@@ -142,7 +142,8 @@ abstract class SettingBoxKey {
|
||||
silentDownImg = 'silentDownImg',
|
||||
showMemberShop = 'showMemberShop',
|
||||
enablePlayAll = 'enablePlayAll',
|
||||
enableTapDm = 'enableTapDm';
|
||||
enableTapDm = 'enableTapDm',
|
||||
setSystemBrightness = 'setSystemBrightness';
|
||||
|
||||
static const String minimizeOnExit = 'minimizeOnExit',
|
||||
windowSize = 'windowSize',
|
||||
|
||||
@@ -865,4 +865,7 @@ abstract class Pref {
|
||||
|
||||
static bool get showTrayIcon =>
|
||||
_setting.get(SettingBoxKey.showTrayIcon, defaultValue: true);
|
||||
|
||||
static bool get setSystemBrightness =>
|
||||
_setting.get(SettingBoxKey.setSystemBrightness, defaultValue: false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user