isLoading method
Latest value can be null
Implementation
bool isLoading(VideoPlayerValue? latestValue) {
if (latestValue != null) {
if (!latestValue.isPlaying && latestValue.duration == null) {
return true;
}
final Duration position = latestValue.position;
Duration? bufferedEndPosition;
if (latestValue.buffered.isNotEmpty == true) {
bufferedEndPosition = latestValue.buffered.last.end;
}
if (bufferedEndPosition != null) {
final difference = bufferedEndPosition - position;
if (latestValue.isPlaying &&
latestValue.isBuffering &&
difference.inMilliseconds < _bufferingInterval) {
return true;
}
}
}
return false;
}