提交 c24d98cd authored 作者: jungleiOS's avatar jungleiOS

loading 组件背景设为黑色,挡住亮度组件初始化时闪现问题,退出播放器恢复亮度

上级 2abe3aa0
差异被折叠。
...@@ -121,7 +121,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -121,7 +121,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
bool _initialized = false; bool _initialized = false;
/// 屏幕亮度 /// 屏幕亮度
final ValueNotifier<double> _brightness = ValueNotifier(0.5); final ValueNotifier<double> _brightness = ValueNotifier(0.0);
late double _originBrightness;
/// 视频音量 /// 视频音量
final ValueNotifier<double> _volume = ValueNotifier(0.5); final ValueNotifier<double> _volume = ValueNotifier(0.5);
...@@ -221,14 +222,18 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -221,14 +222,18 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
/// 常亮 /// 常亮
Wakelock.toggle(enable: true); Wakelock.toggle(enable: true);
/// 初始化亮度为系统亮度 /// 初始化亮度为系统亮度
ScreenBrightness().current.then((brightness) { initBrightness();
_brightness.value = brightness;
});
/// 倍数按钮标题 /// 倍数按钮标题
_speedTitle = widget.videoStyle.videoSpeedButtonStyle.title; _speedTitle = widget.videoStyle.videoSpeedButtonStyle.title;
_initPlayer(); _initPlayer();
} }
void initBrightness() async {
double brightness = await ScreenBrightness().current;
_brightness.value = brightness;
_originBrightness = brightness;
}
@override @override
void didUpdateWidget(GZVideoPlayer oldWidget) { void didUpdateWidget(GZVideoPlayer oldWidget) {
if (oldWidget.dataSource != widget.dataSource) { if (oldWidget.dataSource != widget.dataSource) {
...@@ -251,6 +256,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -251,6 +256,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
_subscription.cancel(); _subscription.cancel();
_brightness.dispose(); _brightness.dispose();
_volume.dispose(); _volume.dispose();
ScreenBrightness().setScreenBrightness(_originBrightness);
super.dispose(); super.dispose();
} }
......
...@@ -8,27 +8,30 @@ class VideoLoadingView extends StatelessWidget { ...@@ -8,27 +8,30 @@ class VideoLoadingView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Align( return DecoratedBox(
alignment: Alignment.center, decoration: const BoxDecoration(color: Colors.black),
child: Center( child: Align(
child: Column( alignment: Alignment.center,
crossAxisAlignment: CrossAxisAlignment.center, child: Center(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: <Widget>[ crossAxisAlignment: CrossAxisAlignment.center,
loadingStyle.customLoadingIcon, mainAxisAlignment: MainAxisAlignment.center,
loadingStyle.customLoadingText != null children: <Widget>[
? loadingStyle.customLoadingText! loadingStyle.customLoadingIcon,
: Container( loadingStyle.customLoadingText != null
margin: const EdgeInsets.only(top: 10), ? loadingStyle.customLoadingText!
child: Text( : Container(
loadingStyle.loadingText, margin: const EdgeInsets.only(top: 10),
style: TextStyle( child: Text(
color: loadingStyle.loadingTextFontColor, loadingStyle.loadingText,
fontSize: loadingStyle.loadingTextFontSize, style: TextStyle(
color: loadingStyle.loadingTextFontColor,
fontSize: loadingStyle.loadingTextFontSize,
),
), ),
), )
) ],
], ),
), ),
), ),
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论