isBuffering property

bool get isBuffering

True if the video is currently buffering.

For Android, this works around a bug in the video_player plugin by checking the actual buffer position vs playback position.

Implementation

bool get isBuffering {
  if (defaultTargetPlatform == TargetPlatform.android) {
    if (_isBuffering) {
      // Special case, if the video is finished, don't show buffering indicator
      final int positionMs = position.inMilliseconds;
      if (positionMs >= duration.inMilliseconds) {
        return false;
      }

      // Get the last buffered range, or -1 if none exists
      final int bufferMs =
          buffered.isNotEmpty ? buffered.last.end.inMilliseconds : -1;

      return positionMs >= bufferMs;
    }
    return false;
  }

  return _isBuffering;
}