registMethodChannelCallHandler static method

void registMethodChannelCallHandler()

Implementation

static void registMethodChannelCallHandler() {
  if (_methodChannelCallHandlerIsRegisted == true) {
    return;
  }
  _methodChannelCallHandlerIsRegisted = true;
  _methodChannel.setMethodCallHandler((MethodCall call) async {
    switch (call.method) {
      case 'onMasterM3U8PlaylistSelectPreloadUrls':
        String json = call.arguments;
        Map<String, dynamic> decodedJson = jsonDecode(json);
        TTMasterPlaylist playlist = TTMasterPlaylist.fromJson(decodedJson);
        if (_onMasterM3U8PlaylistSelectPreloadUrls != null) {
          List<TTMasterPreloadURLInfo>? urlInfos = _onMasterM3U8PlaylistSelectPreloadUrls!.call(playlist);
          return jsonEncode(urlInfos);
        }
        break;
      default:
        break;
    }
  });
}