getPosition method

  1. @override
Future<Duration> getPosition()
override

Retrieves the current playback position of the player.

Implementation

@override
Future<Duration> getPosition() async {
  try {
    // Convert the retrieved position to a Duration object.
    return Duration(
      seconds: int.parse(
          ((await _methodChannel.invokeMethod("position")).toString())
              .split(".")
              .first),
    );
  } catch (e) {
    log(e.toString());
    throw Exception(
        "Unable to retrieve the current playback position [Get Position]");
  }
}