/// GENERATED BY terra, DO NOT MODIFY BY HAND.

// ignore_for_file: public_member_api_docs, unused_local_variable, unused_import, annotate_overrides

import 'package:agora_rtc_engine/src/binding_forward_export.dart';
import 'package:agora_rtc_engine/src/binding/impl_forward_export.dart';
import 'package:iris_method_channel/iris_method_channel.dart';

class MediaPlayerImpl implements MediaPlayer {
  MediaPlayerImpl(this.irisMethodChannel);

  @protected
  final IrisMethodChannel irisMethodChannel;

  @protected
  Map<String, dynamic> createParams(Map<String, dynamic> param) {
    return param;
  }

  @protected
  bool get isOverrideClassName => false;

  @protected
  String get className => 'MediaPlayer';

  @override
  int getMediaPlayerId() {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_getMediaPlayerId';
// final param = createParams({
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// return result as int;
    throw UnimplementedError('Unimplement for getMediaPlayerId');
  }

  @override
  Future<void> open({required String url, required int startPos}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_open_e43f201';
    final param = createParams({'url': url, 'startPos': startPos});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> openWithMediaSource(MediaSource source) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_openWithMediaSource_3c11499';
    final param = createParams({'source': source.toJson()});
    final List<Uint8List> buffers = [];
    buffers.addAll(source.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> play() async {
    final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_play';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> pause() async {
    final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_pause';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> stop() async {
    final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_stop';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> resume() async {
    final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_resume';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> seek(int newPos) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_seek_f631116';
    final param = createParams({'newPos': newPos});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setAudioPitch(int pitch) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setAudioPitch_46f8ab7';
    final param = createParams({'pitch': pitch});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<int> getDuration() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getDuration_b12f121';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getDurationJson = MediaPlayerGetDurationJson.fromJson(rm);
    return getDurationJson.duration;
  }

  @override
  Future<int> getPlayPosition() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getPlayPosition_b12f121';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getPlayPositionJson = MediaPlayerGetPlayPositionJson.fromJson(rm);
    return getPlayPositionJson.pos;
  }

  @override
  Future<int> getStreamCount() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getStreamCount_b12f121';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getStreamCountJson = MediaPlayerGetStreamCountJson.fromJson(rm);
    return getStreamCountJson.count;
  }

  @override
  Future<PlayerStreamInfo> getStreamInfo(int index) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getStreamInfo_0fa63fa';
    final param = createParams({'index': index});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getStreamInfoJson = MediaPlayerGetStreamInfoJson.fromJson(rm);
    return getStreamInfoJson.info;
  }

  @override
  Future<void> setLoopCount(int loopCount) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setLoopCount_46f8ab7';
    final param = createParams({'loopCount': loopCount});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setPlaybackSpeed(int speed) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setPlaybackSpeed_46f8ab7';
    final param = createParams({'speed': speed});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> selectAudioTrack(int index) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_selectAudioTrack_46f8ab7';
    final param = createParams({'index': index});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> selectMultiAudioTrack(
      {required int playoutTrackIndex, required int publishTrackIndex}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_selectMultiAudioTrack_4e92b3c';
    final param = createParams({
      'playoutTrackIndex': playoutTrackIndex,
      'publishTrackIndex': publishTrackIndex
    });
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> takeScreenshot(String filename) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_takeScreenshot_3a2037f';
    final param = createParams({'filename': filename});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> selectInternalSubtitle(int index) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_selectInternalSubtitle_46f8ab7';
    final param = createParams({'index': index});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setExternalSubtitle(String url) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setExternalSubtitle_3a2037f';
    final param = createParams({'url': url});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<MediaPlayerState> getState() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getState';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return MediaPlayerStateExt.fromValue(result);
  }

  @override
  Future<void> mute(bool muted) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_mute_5039d15';
    final param = createParams({'muted': muted});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<bool> getMute() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getMute_c93e9d4';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getMuteJson = MediaPlayerGetMuteJson.fromJson(rm);
    return getMuteJson.muted;
  }

  @override
  Future<void> adjustPlayoutVolume(int volume) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_adjustPlayoutVolume_46f8ab7';
    final param = createParams({'volume': volume});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<int> getPlayoutVolume() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getPlayoutVolume_9cfaa7e';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getPlayoutVolumeJson = MediaPlayerGetPlayoutVolumeJson.fromJson(rm);
    return getPlayoutVolumeJson.volume;
  }

  @override
  Future<void> adjustPublishSignalVolume(int volume) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_adjustPublishSignalVolume_46f8ab7';
    final param = createParams({'volume': volume});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<int> getPublishSignalVolume() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getPublishSignalVolume_9cfaa7e';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getPublishSignalVolumeJson =
        MediaPlayerGetPublishSignalVolumeJson.fromJson(rm);
    return getPublishSignalVolumeJson.volume;
  }

  @override
  Future<void> setView(int view) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setView_cb1a81f';
    final param = createParams({'view': view});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setRenderMode(RenderModeType renderMode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setRenderMode_bedb5ae';
    final param = createParams({'renderMode': renderMode.value()});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  void registerPlayerSourceObserver(MediaPlayerSourceObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_registerPlayerSourceObserver_15621d7';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for registerPlayerSourceObserver');
  }

  @override
  void unregisterPlayerSourceObserver(MediaPlayerSourceObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_unregisterPlayerSourceObserver_15621d7';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for unregisterPlayerSourceObserver');
  }

  @override
  void registerAudioFrameObserver(
      {required AudioPcmFrameSink observer,
      RawAudioFrameOpModeType mode =
          RawAudioFrameOpModeType.rawAudioFrameOpModeReadOnly}) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_registerAudioFrameObserver_a5b510b';
// final param = createParams({
//   'observer': observer,'mode': mode.value()
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for registerAudioFrameObserver');
  }

  @override
  void unregisterAudioFrameObserver(AudioPcmFrameSink observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_unregisterAudioFrameObserver_89ab9b5';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for unregisterAudioFrameObserver');
  }

  @override
  void registerVideoFrameObserver(MediaPlayerVideoFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_registerVideoFrameObserver_833bd8d';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for registerVideoFrameObserver');
  }

  @override
  void unregisterVideoFrameObserver(MediaPlayerVideoFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_unregisterVideoFrameObserver_5165d4c';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for unregisterVideoFrameObserver');
  }

  @override
  void registerMediaPlayerAudioSpectrumObserver(
      {required AudioSpectrumObserver observer, required int intervalInMS}) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_registerMediaPlayerAudioSpectrumObserver_226bb48';
// final param = createParams({
//   'observer': observer,'intervalInMS': intervalInMS
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError(
        'Unimplement for registerMediaPlayerAudioSpectrumObserver');
  }

  @override
  void unregisterMediaPlayerAudioSpectrumObserver(
      AudioSpectrumObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaPlayer'}_unregisterMediaPlayerAudioSpectrumObserver_09064ce';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError(
        'Unimplement for unregisterMediaPlayerAudioSpectrumObserver');
  }

  @override
  Future<void> setAudioDualMonoMode(AudioDualMonoMode mode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setAudioDualMonoMode_30c9672';
    final param = createParams({'mode': mode.value()});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<String> getPlayerSdkVersion() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getPlayerSdkVersion';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as String;
  }

  @override
  Future<String> getPlaySrc() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getPlaySrc';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as String;
  }

  @override
  Future<void> openWithAgoraCDNSrc(
      {required String src, required int startPos}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_openWithAgoraCDNSrc_e43f201';
    final param = createParams({'src': src, 'startPos': startPos});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<int> getAgoraCDNLineCount() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getAgoraCDNLineCount';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as int;
  }

  @override
  Future<void> switchAgoraCDNLineByIndex(int index) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_switchAgoraCDNLineByIndex_46f8ab7';
    final param = createParams({'index': index});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<int> getCurrentAgoraCDNIndex() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_getCurrentAgoraCDNIndex';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as int;
  }

  @override
  Future<void> enableAutoSwitchAgoraCDN(bool enable) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_enableAutoSwitchAgoraCDN_5039d15';
    final param = createParams({'enable': enable});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> renewAgoraCDNSrcToken(
      {required String token, required int ts}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_renewAgoraCDNSrcToken_e43f201';
    final param = createParams({'token': token, 'ts': ts});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> switchAgoraCDNSrc(
      {required String src, bool syncPts = false}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_switchAgoraCDNSrc_7a174df';
    final param = createParams({'src': src, 'syncPts': syncPts});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> switchSrc({required String src, bool syncPts = true}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_switchSrc_7a174df';
    final param = createParams({'src': src, 'syncPts': syncPts});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> preloadSrc({required String src, required int startPos}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_preloadSrc_e43f201';
    final param = createParams({'src': src, 'startPos': startPos});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> playPreloadedSrc(String src) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_playPreloadedSrc_3a2037f';
    final param = createParams({'src': src});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> unloadSrc(String src) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_unloadSrc_3a2037f';
    final param = createParams({'src': src});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setSpatialAudioParams(SpatialAudioParams params) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setSpatialAudioParams_5035667';
    final param = createParams({'params': params.toJson()});
    final List<Uint8List> buffers = [];
    buffers.addAll(params.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setSoundPositionParams(
      {required double pan, required double gain}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setSoundPositionParams_f282d50';
    final param = createParams({'pan': pan, 'gain': gain});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setPlayerOptionInInt(
      {required String key, required int value}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setPlayerOption_4d05d29';
    final param = createParams({'key': key, 'value': value});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setPlayerOptionInString(
      {required String key, required String value}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayer'}_setPlayerOption_ccad422';
    final param = createParams({'key': key, 'value': value});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }
}

class MediaPlayerCacheManagerImpl implements MediaPlayerCacheManager {
  MediaPlayerCacheManagerImpl(this.irisMethodChannel);

  @protected
  final IrisMethodChannel irisMethodChannel;

  @protected
  Map<String, dynamic> createParams(Map<String, dynamic> param) {
    return param;
  }

  @protected
  bool get isOverrideClassName => false;

  @protected
  String get className => 'MediaPlayerCacheManager';

  @override
  Future<void> removeAllCaches() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_removeAllCaches';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> removeOldCache() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_removeOldCache';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> removeCacheByUri(String uri) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_removeCacheByUri_3a2037f';
    final param = createParams({'uri': uri});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setCacheDir(String path) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_setCacheDir_3a2037f';
    final param = createParams({'path': path});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setMaxCacheFileCount(int count) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_setMaxCacheFileCount_46f8ab7';
    final param = createParams({'count': count});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setMaxCacheFileSize(int cacheSize) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_setMaxCacheFileSize_f631116';
    final param = createParams({'cacheSize': cacheSize});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> enableAutoRemoveCache(bool enable) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_enableAutoRemoveCache_5039d15';
    final param = createParams({'enable': enable});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<String> getCacheDir(int length) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_getCacheDir_c9551e8';
    final param = createParams({'length': length});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
    final getCacheDirJson = MediaPlayerCacheManagerGetCacheDirJson.fromJson(rm);
    return getCacheDirJson.path;
  }

  @override
  Future<int> getMaxCacheFileCount() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_getMaxCacheFileCount';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as int;
  }

  @override
  Future<int> getMaxCacheFileSize() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_getMaxCacheFileSize';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as int;
  }

  @override
  Future<int> getCacheFileCount() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaPlayerCacheManager'}_getCacheFileCount';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as int;
  }
}
