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

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

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