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

播放结束视频比例调整 position duration 不置为--:--

上级 8a544176
......@@ -175,6 +175,9 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
/// 多播放器实例设置唯一key
Key key = Key(DateTime.now().toString());
/// 视频比例
double _playerAspectRatio = 1.0;
late StreamSubscription<ConnectivityResult> _subscription;
@override
......@@ -333,8 +336,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
void resetVideoPlayer() {
setState(() {
_isEnded = true;
_position = "--:--";
_duration = "--:--";
// _position = "--:--";
// _duration = "--:--";
_controller.value =
const VideoPlayerValue(duration: Duration(seconds: 0));
});
......@@ -381,7 +384,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
});
} else {
if (oPosition >= oDuration) {
// resetVideoPlayer();
resetVideoPlayer();
if (widget.onEnded != null) {
widget.onEnded!(_controller.value);
}
......@@ -398,6 +401,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
setVolume(_volume.value);
widget.onInit?.call(_controller);
_initialized = true;
_playerAspectRatio = _controller.value.aspectRatio;
setState(() {});
if (widget.playOptions.autoplay) {
if (widget.playOptions.startPosition.inSeconds != 0) {
......@@ -987,7 +991,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
color: Colors.black,
child: Center(
child: AspectRatio(
aspectRatio: _controller.value.aspectRatio,
aspectRatio: _playerAspectRatio,
child: VideoPlayer(_controller),
),
),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论