onPlayerVisibilityChanged method
Listener which handles state of player visibility. If player visibility is below 0.0 then video will be paused. When value is greater than 0, video will play again. If there's different handler of visibility then it will be used. If showNotification is set in data source or handleLifecycle is false then this logic will be ignored.
Implementation
void onPlayerVisibilityChanged(double visibilityFraction) async {
_isPlayerVisible = visibilityFraction > 0;
if (_disposed) {
return;
}
_postEvent(
BetterPlayerEvent(BetterPlayerEventType.changedPlayerVisibility));
if (_isAutomaticPlayPauseHandled()) {
if (betterPlayerConfiguration.playerVisibilityChangedBehavior != null) {
betterPlayerConfiguration
.playerVisibilityChangedBehavior!(visibilityFraction);
} else {
if (visibilityFraction == 0) {
_wasPlayingBeforePause ??= isPlaying();
pause();
} else {
if (_wasPlayingBeforePause == true && !isPlaying()!) {
play();
}
}
}
}
}