getDuration method

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

Returns the duration of the media, 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?> getDuration(String playerId) async {
  final jsDuration = getPlayer(playerId).player?.duration;
  if (jsDuration == null) {
    return null;
  }
  return jsDuration.fromSecondsToDuration().inMilliseconds;
}