/// 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 MusicChartCollectionImpl implements MusicChartCollection {
  MusicChartCollectionImpl(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 => 'MusicChartCollection';

  @override
  Future<int> getCount() async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicChartCollection'}_getCount';
    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<MusicChartInfo> get(int index) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicChartCollection'}_get_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'];
    return result as MusicChartInfo;
  }
}

class MusicCollectionImpl implements MusicCollection {
  MusicCollectionImpl(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 => 'MusicCollection';

  @override
  int getCount() {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicCollection'}_getCount';
// 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 getCount');
  }

  @override
  int getTotal() {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicCollection'}_getTotal';
// 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 getTotal');
  }

  @override
  int getPage() {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicCollection'}_getPage';
// 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 getPage');
  }

  @override
  int getPageSize() {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicCollection'}_getPageSize';
// 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 getPageSize');
  }

  @override
  Music getMusic(int index) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicCollection'}_getMusic_8fcdcef';
// 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'];
// return result as Music;
    throw UnimplementedError('Unimplement for getMusic');
  }
}

class MusicPlayerImpl extends MediaPlayerImpl implements MusicPlayer {
  MusicPlayerImpl(IrisMethodChannel irisMethodChannel)
      : super(irisMethodChannel);

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

  @override
  @protected
  bool get isOverrideClassName => false;

  @override
  @protected
  String get className => 'MusicPlayer';

  @override
  Future<void> setPlayMode(MusicPlayMode mode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicPlayer'}_setPlayMode_748bee0';
    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<void> openWithSongCode(
      {required int songCode, int startPos = 0}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicPlayer'}_open_303b92e';
    final param = createParams({'songCode': songCode, '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);
    }
  }
}

class MusicContentCenterImpl implements MusicContentCenter {
  MusicContentCenterImpl(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 => 'MusicContentCenter';

  @override
  Future<void> initialize(MusicContentCenterConfiguration configuration) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_initialize_df70304';
    final param = createParams({'configuration': configuration.toJson()});
    final List<Uint8List> buffers = [];
    buffers.addAll(configuration.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> renewToken(String token) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_renewToken_3a2037f';
    final param = createParams({'token': token});
    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> release() async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_release';
    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
  void registerEventHandler(MusicContentCenterEventHandler eventHandler) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicContentCenter'}_registerEventHandler_ae49451';
// final param = createParams({
//   'eventHandler': eventHandler
// });
// 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 registerEventHandler');
  }

  @override
  void unregisterEventHandler() {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MusicContentCenter'}_unregisterEventHandler';
// 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); }
    throw UnimplementedError('Unimplement for unregisterEventHandler');
  }

  @override
  Future<MusicPlayer?> createMusicPlayer() async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_createMusicPlayer';
    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 MusicPlayer;
  }

  @override
  Future<void> destroyMusicPlayer(MusicPlayer musicPlayer) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_destroyMusicPlayer_876d086';
    final param = createParams({'music_player': musicPlayer});
    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> getMusicCharts() async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_getMusicCharts_66d4ecd';
    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 getMusicChartsJson =
        MusicContentCenterGetMusicChartsJson.fromJson(rm);
    return getMusicChartsJson.requestId;
  }

  @override
  Future<String> getMusicCollectionByMusicChartId(
      {required int musicChartId,
      required int page,
      required int pageSize,
      String? jsonOption}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_getMusicCollectionByMusicChartId_8cd0b4d';
    final param = createParams({
      'musicChartId': musicChartId,
      'page': page,
      'pageSize': pageSize,
      if (jsonOption != null) 'jsonOption': jsonOption
    });
    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 getMusicCollectionByMusicChartIdJson =
        MusicContentCenterGetMusicCollectionByMusicChartIdJson.fromJson(rm);
    return getMusicCollectionByMusicChartIdJson.requestId;
  }

  @override
  Future<String> searchMusic(
      {required String keyWord,
      required int page,
      required int pageSize,
      String? jsonOption}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_searchMusic_3f8cf09';
    final param = createParams({
      'keyWord': keyWord,
      'page': page,
      'pageSize': pageSize,
      if (jsonOption != null) 'jsonOption': jsonOption
    });
    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 searchMusicJson = MusicContentCenterSearchMusicJson.fromJson(rm);
    return searchMusicJson.requestId;
  }

  @override
  Future<String> preload(int songCode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_preload_d3baeab';
    final param = createParams({'songCode': songCode});
    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 preloadJson = MusicContentCenterPreloadJson.fromJson(rm);
    return preloadJson.requestId;
  }

  @override
  Future<void> removeCache(int songCode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_removeCache_f631116';
    final param = createParams({'songCode': songCode});
    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<List<MusicCacheInfo>> getCaches(int cacheInfoSize) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_getCaches_c4f9978';
    final param = createParams({'cacheInfoSize': cacheInfoSize});
    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 getCachesJson = MusicContentCenterGetCachesJson.fromJson(rm);
    return getCachesJson.cacheInfo;
  }

  @override
  Future<bool> isPreloaded(int songCode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_isPreloaded_f631116';
    final param = createParams({'songCode': songCode});
    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 bool;
  }

  @override
  Future<String> getLyric({required int songCode, int lyricType = 0}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_getLyric_5ab5efd';
    final param = createParams({'songCode': songCode, 'lyricType': lyricType});
    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 getLyricJson = MusicContentCenterGetLyricJson.fromJson(rm);
    return getLyricJson.requestId;
  }

  @override
  Future<String> getSongSimpleInfo(int songCode) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_getSongSimpleInfo_d3baeab';
    final param = createParams({'songCode': songCode});
    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 getSongSimpleInfoJson =
        MusicContentCenterGetSongSimpleInfoJson.fromJson(rm);
    return getSongSimpleInfoJson.requestId;
  }

  @override
  Future<int> getInternalSongCode(
      {required int songCode, required String jsonOption}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MusicContentCenter'}_getInternalSongCode_3a3d1e7';
    final param =
        createParams({'songCode': songCode, 'jsonOption': jsonOption});
    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 getInternalSongCodeJson =
        MusicContentCenterGetInternalSongCodeJson.fromJson(rm);
    return getInternalSongCodeJson.internalSongCode;
  }
}
