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

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

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