setOnPreparePlayer method

void setOnPreparePlayer(
  1. OnPreparePlayer onPreparePlayer
)

Implementation

void setOnPreparePlayer(OnPreparePlayer onPreparePlayer) {
  try {
    _channel.invokeMethod('setOnPreparePlayer');
  } on PlatformException catch (e) {
    logger.e("setOnPreparePlayer error: ${e.details} - ${e.message}");
  }

  _channel.setMethodCallHandler((call) async {
    switch (call.method) {
      // callback of onPreparePlayer
      case 'onPrepareContentError':
        final errorCode = call.arguments['errorCode'] as int;
        final message = call.arguments['message'] as String;
        logger.d("setMethodCallHandler onPrepareContentError $message");
        onPreparePlayer.onPrepareContentError(errorCode, message);
        break;
      case 'onPlayerPreparing':
        logger.d("setMethodCallHandler onPlayerPreparing");
        onPreparePlayer.onPlayerPreparing();
        break;
      case 'onPlayerReleased':
        logger.d("setMethodCallHandler onPlayerReleased");
        onPreparePlayer.onPlayerReleased();
        break;
      case 'onPlayerPrepared':
        logger.d("setMethodCallHandler onPlayerPrepared");
        onPreparePlayer.onPlayerPrepared();
        break;
      case 'onLogEventListener':
        final event = call.arguments['event'] as String;
        logger.d("setMethodCallHandler onLogEventListener event = $event");
        onPreparePlayer.onLogEventListener(event);
        break;
      case 'isLiveStream':
        final isLiveStream = call.arguments['isLiveStream'] as bool;
        logger.d("setMethodCallHandler isLiveStream = $isLiveStream");
        onPreparePlayer.isLiveStream(isLiveStream);
        break;
      case 'isDisableShowCCU':
        final isShow = call.arguments['isShow'] as bool;
        logger.d("setMethodCallHandler isDisableShowCCU isShow = $isShow");
        onPreparePlayer.isDisableShowCCU(isShow);
        break;
      case 'onHeartBeat':
        final status = call.arguments['status'] as String;
        final backgroundLive = call.arguments['backgroundLive'] as String;
        final titleLive = call.arguments['titleLive'] as String;
        final timeEventLive = call.arguments['timeEventLive'] as int;
        final source = call.arguments['source'] as String;
        logger.d("setMethodCallHandler onHeartBeat status = $status, backgroundLive = $backgroundLive, titleLive = $titleLive, timeEventLive = $timeEventLive, source = $source");
        onPreparePlayer.onHeartBeat(
            status, backgroundLive, titleLive, timeEventLive, source);
        break;
    }
  });
}