getDuration static method

Future<int> getDuration({
  1. required int playerId,
})

Implementation

static Future<int> getDuration({required int playerId}) async {
  const channel = BasicMessageChannel<dynamic>('io.github.wangyng.simple_audio_player.getDuration', StandardMessageCodec());

  final Map<String, dynamic> requestMap = {};
  requestMap["playerId"] = playerId;
  final reply = await channel.send(requestMap);

  if (!(reply is Map)) {
    _throwChannelException();
  }

  final replyMap = Map<String, dynamic>.from(reply);
  if (replyMap['error'] != null) {
    final error = Map<String, dynamic>.from(replyMap['error']);
    _throwException(error);
    return 0;
  } else {
    return replyMap["result"];
  }
}