mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: video brightness control
This commit is contained in:
@@ -76,7 +76,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
|||||||
subTitle: '返回时自动调整视频亮度',
|
subTitle: '返回时自动调整视频亮度',
|
||||||
leading: Icon(Icons.brightness_6_outlined),
|
leading: Icon(Icons.brightness_6_outlined),
|
||||||
setKey: SettingBoxKey.enableAutoBrightness,
|
setKey: SettingBoxKey.enableAutoBrightness,
|
||||||
defaultVal: false,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '免登录1080P',
|
title: '免登录1080P',
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
|||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:PiliPalaX/utils/video_utils.dart';
|
import 'package:PiliPalaX/utils/video_utils.dart';
|
||||||
import 'package:screen_brightness/screen_brightness.dart';
|
|
||||||
|
|
||||||
import '../../../utils/id_utils.dart';
|
import '../../../utils/id_utils.dart';
|
||||||
import 'widgets/header_control.dart';
|
import 'widgets/header_control.dart';
|
||||||
@@ -235,13 +234,6 @@ class VideoDetailController extends GetxController
|
|||||||
duration,
|
duration,
|
||||||
bool autoplay = true,
|
bool autoplay = true,
|
||||||
}) async {
|
}) async {
|
||||||
/// 设置/恢复 屏幕亮度
|
|
||||||
if (brightness != null) {
|
|
||||||
ScreenBrightness().setScreenBrightness(brightness!);
|
|
||||||
} else if (setting.get(SettingBoxKey.enableAutoBrightness,
|
|
||||||
defaultValue: false) as bool) {
|
|
||||||
ScreenBrightness().resetScreenBrightness();
|
|
||||||
}
|
|
||||||
await plPlayerController.setDataSource(
|
await plPlayerController.setDataSource(
|
||||||
DataSource(
|
DataSource(
|
||||||
videoSource: video ?? videoUrl,
|
videoSource: video ?? videoUrl,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
|||||||
import 'package:PiliPalaX/plugin/pl_player/models/play_repeat.dart';
|
import 'package:PiliPalaX/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:PiliPalaX/services/service_locator.dart';
|
import 'package:PiliPalaX/services/service_locator.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
|
import 'package:screen_brightness/screen_brightness.dart';
|
||||||
|
|
||||||
import '../../../services/shutdown_timer_service.dart';
|
import '../../../services/shutdown_timer_service.dart';
|
||||||
import 'widgets/header_control.dart';
|
import 'widgets/header_control.dart';
|
||||||
@@ -277,6 +278,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
ScreenBrightness().resetScreenBrightness();
|
||||||
appbarStream.close();
|
appbarStream.close();
|
||||||
floating.dispose();
|
floating.dispose();
|
||||||
videoDetailController.floating?.dispose();
|
videoDetailController.floating?.dispose();
|
||||||
@@ -305,8 +307,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
void didPushNext() async {
|
void didPushNext() async {
|
||||||
// _bufferedListener?.cancel();
|
// _bufferedListener?.cancel();
|
||||||
|
|
||||||
|
ScreenBrightness().resetScreenBrightness();
|
||||||
|
|
||||||
/// 开启
|
/// 开启
|
||||||
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
|
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: true)
|
||||||
as bool) {
|
as bool) {
|
||||||
videoDetailController.brightness = plPlayerController!.brightness.value;
|
videoDetailController.brightness = plPlayerController!.brightness.value;
|
||||||
}
|
}
|
||||||
@@ -318,9 +322,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
plPlayerController!.pause();
|
plPlayerController!.pause();
|
||||||
}
|
}
|
||||||
isShowing = false;
|
isShowing = false;
|
||||||
if (mounted) {
|
|
||||||
setState(() => {});
|
|
||||||
}
|
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,15 +329,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// 返回当前页面时
|
// 返回当前页面时
|
||||||
void didPopNext() async {
|
void didPopNext() async {
|
||||||
isShowing = true;
|
isShowing = true;
|
||||||
if (mounted) {
|
|
||||||
setState(() => {});
|
|
||||||
}
|
|
||||||
super.didPopNext();
|
super.didPopNext();
|
||||||
videoDetailController.isFirstTime = false;
|
videoDetailController.isFirstTime = false;
|
||||||
final bool autoplay = autoPlayEnable;
|
final bool autoplay = autoPlayEnable;
|
||||||
videoDetailController.autoPlay.value =
|
videoDetailController.autoPlay.value =
|
||||||
!videoDetailController.isShowCover.value;
|
!videoDetailController.isShowCover.value;
|
||||||
await videoDetailController.playerInit(autoplay: autoplay);
|
await videoDetailController.playerInit(autoplay: autoplay);
|
||||||
|
if (mounted && videoDetailController.brightness != null) {
|
||||||
|
ScreenBrightness().setScreenBrightness(videoDetailController.brightness!);
|
||||||
|
}
|
||||||
|
|
||||||
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
||||||
videoIntroController.isPaused = false;
|
videoIntroController.isPaused = false;
|
||||||
|
|||||||
@@ -1453,10 +1453,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// 销毁播放器实例
|
// 销毁播放器实例
|
||||||
// await widget.controller!.dispose(type: 'all');
|
// await widget.controller!.dispose(type: 'all');
|
||||||
if (mounted) {
|
Get.until((route) => route.isFirst);
|
||||||
Navigator.popUntil(
|
|
||||||
context, (Route<dynamic> route) => route.isFirst);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
if ((videoIntroController.videoDetail.value.title != null) &&
|
if ((videoIntroController.videoDetail.value.title != null) &&
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ class PlPlayerController {
|
|||||||
|
|
||||||
// Future.delayed(const Duration(milliseconds: 100), () {
|
// Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
// getCurrentVolume();
|
// getCurrentVolume();
|
||||||
// if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
|
// if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: true)
|
||||||
// as bool) {
|
// as bool) {
|
||||||
// getCurrentBrightness();
|
// getCurrentBrightness();
|
||||||
// }
|
// }
|
||||||
@@ -1321,7 +1321,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
_instance = null;
|
_instance = null;
|
||||||
// 关闭所有视频页面恢复亮度
|
// 关闭所有视频页面恢复亮度
|
||||||
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
|
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: true)
|
||||||
as bool) {
|
as bool) {
|
||||||
resetBrightness();
|
resetBrightness();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user