Skip to content

Commit

Permalink
解决loading异常
Browse files Browse the repository at this point in the history
  • Loading branch information
DyncMark committed Apr 18, 2020
1 parent e722497 commit f8bf2ce
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/src/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
/// 是否全屏
bool fullscreened = false;
bool initialized = false;
bool isReplaying = false;

/// 屏幕亮度
double brightness;
Expand Down Expand Up @@ -197,6 +196,7 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
controller.pause();
}
updateDataSource();
controller.play();
}
super.didUpdateWidget(oldWidget);
}
Expand All @@ -220,7 +220,6 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
controller = createVideoPlayerController()
..addListener(listener)
..initialize().then(handleInit);
isReplaying = true;
});
}

Expand Down Expand Up @@ -294,15 +293,12 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
}
initialized = true;
setState(() {});
if (widget.playOptions.autoplay || isReplaying) {
if (widget.playOptions.autoplay) {
if (widget.playOptions.startPosition.inSeconds != 0) {
controller.seekTo(widget.playOptions.startPosition);
}
controller.play();
if (isReplaying) {
isEnded = false;
isReplaying = false;
}
isEnded = false;
}
}

Expand Down Expand Up @@ -557,7 +553,7 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
/// 是否显示播放按钮
widget.videoStyle.showPlayIcon &&
initialized &&
(!controller.value.isPlaying && !isEnded && !isReplaying) &&
(!controller.value.isPlaying && !isEnded) &&
!isBuffing
? Align(
alignment: Alignment.center,
Expand All @@ -578,7 +574,9 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
alignment: Alignment.center,
child: GestureDetector(
onTap: () {
isEnded = false;
updateDataSource();
controller.play();
},
child: widget.videoStyle.replayIcon,
),
Expand Down Expand Up @@ -629,7 +627,7 @@ class _AwsomeVideoPlayerState extends State<AwsomeVideoPlayer>
),

/// Loading
!initialized || isBuffing || isReplaying
!initialized || isBuffing
? VideoLoadingView(loadingStyle: widget.videoStyle.videoLoadingStyle)
: Align()
];
Expand Down

0 comments on commit f8bf2ce

Please sign in to comment.