getCurrentPosition method

  1. @override
Future<int?> getCurrentPosition(
  1. String playerId
)

Returns the current position of playback, in milliseconds, if available.

Might not be available if:

  • source has not been set or prepared yet (for remote audios it must be downloaded and buffered first)
  • source does not support operation (e.g. streams)
  • otherwise not supported (e.g. LOW_LATENCY mode on Android)

Implementation

@override
Future<int?> getCurrentPosition(String playerId) async {
  final position = getPlayer(playerId).player?.currentTime;
  if (position == null) {
    return null;
  }
  return (position * 1000).toInt();
}