提交 993eb30c authored 作者: jungleiOS's avatar jungleiOS

dispose 时销毁动画控制器 重置按钮不根据结束回调是否实现而显示

上级 6abf309a
...@@ -213,6 +213,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -213,6 +213,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
]); ]);
// 常亮 // 常亮
Wakelock.toggle(enable: true); Wakelock.toggle(enable: true);
/// 倍数按钮标题 /// 倍数按钮标题
_speedTitle = widget.videoStyle.videoSpeedButtonStyle.title; _speedTitle = widget.videoStyle.videoSpeedButtonStyle.title;
_initPlayer(); _initPlayer();
...@@ -230,6 +231,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -230,6 +231,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
void dispose() { void dispose() {
_clearHideControlBarTimer(); _clearHideControlBarTimer();
_controller.dispose(); _controller.dispose();
_controlBarAnimationController.dispose();
///竖屏 ///竖屏
SystemChrome.setPreferredOrientations([ SystemChrome.setPreferredOrientations([
...@@ -308,8 +310,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -308,8 +310,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
}); });
} else { } else {
if (oPosition >= oDuration) { if (oPosition >= oDuration) {
if (widget.onEnded != null) {
resetVideoPlayer(); resetVideoPlayer();
if (widget.onEnded != null) {
widget.onEnded!(_controller.value); widget.onEnded!(_controller.value);
} }
} }
...@@ -638,7 +640,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -638,7 +640,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
: const Text(""), : const Text(""),
/// 主字幕 /// 主字幕
widget.videoStyle.videoSubtitlesStyle.mainTitle ?? Align( widget.videoStyle.videoSubtitlesStyle.mainTitle ??
Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Container( child: Container(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 30), padding: const EdgeInsets.fromLTRB(10, 0, 10, 30),
...@@ -646,15 +649,16 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -646,15 +649,16 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
maxLines: 2, maxLines: 2,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: widget color:
.videoStyle.videoSubtitlesStyle.mainTitleColor, widget.videoStyle.videoSubtitlesStyle.mainTitleColor,
fontSize: widget fontSize: widget
.videoStyle.videoSubtitlesStyle.mainTitleFontSize)), .videoStyle.videoSubtitlesStyle.mainTitleFontSize)),
), ),
), ),
/// 辅字幕 /// 辅字幕
widget.videoStyle.videoSubtitlesStyle.subTitle ?? Align( widget.videoStyle.videoSubtitlesStyle.subTitle ??
Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Container( child: Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
...@@ -690,12 +694,14 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -690,12 +694,14 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
}, },
), ),
widget.brightnessWidget ?? BrightnessWidget( widget.brightnessWidget ??
BrightnessWidget(
brightness: _brightness, brightness: _brightness,
videoBrightnessStyle: widget.videoStyle.videoBrightnessStyle, videoBrightnessStyle: widget.videoStyle.videoBrightnessStyle,
), ),
widget.volumeWidget ?? VolumeWidget( widget.volumeWidget ??
VolumeWidget(
volume: _volume, volume: _volume,
videoVolumeStyle: widget.videoStyle.videoVolumeStyle, videoVolumeStyle: widget.videoStyle.videoVolumeStyle,
), ),
...@@ -760,8 +766,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -760,8 +766,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
if (!_controller.value.isInitialized) return; if (!_controller.value.isInitialized) return;
}, },
onVerticalDragUpdate: (DragUpdateDetails details) async { onVerticalDragUpdate: (DragUpdateDetails details) async {
if (!_controller.value.isInitialized || if (!_controller.value.isInitialized || details.primaryDelta == null)
details.primaryDelta == null) return; return;
// 右侧垂直滑动 - 音量调节 // 右侧垂直滑动 - 音量调节
if (details.globalPosition.dx >= (screenSize.width / 2)) { if (details.globalPosition.dx >= (screenSize.width / 2)) {
_volume.value = _controller.value.volume; _volume.value = _controller.value.volume;
...@@ -825,8 +831,11 @@ class GZVideoPlayerState extends State<GZVideoPlayer> ...@@ -825,8 +831,11 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
child: AspectRatio( child: AspectRatio(
aspectRatio: _controller.value.aspectRatio, aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller), child: VideoPlayer(_controller),
)), ),
))), ),
),
),
),
///控制拦以及(可拓展)元素 ///控制拦以及(可拓展)元素
]; ];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论