create static method

Future<NELivePlayer> create({
  1. void onPreparedListener()?,
  2. void onCompletionListener()?,
  3. void onErrorListener(
    1. PlayerErrorType what,
    2. int extra
    )?,
  4. void onVideoSizeChangedListener(
    1. int width,
    2. int height
    )?,
  5. void onReleasedListener()?,
  6. void onLoadStateChangeListener(
    1. PlayStateType type,
    2. int extra
    )?,
  7. void onFirstVideoDisplayListener()?,
  8. void onFirstAudioDisplayListener()?,
})

创建播放器实例 Create a player instance

Implementation

static Future<NELivePlayer> create({
  void Function()? onPreparedListener,
  void Function()? onCompletionListener,
  void Function(PlayerErrorType what, int extra)? onErrorListener,
  void Function(int width, int height)? onVideoSizeChangedListener,
  void Function()? onReleasedListener,
  void Function(PlayStateType type, int extra)? onLoadStateChangeListener,
  void Function()? onFirstVideoDisplayListener,
  void Function()? onFirstAudioDisplayListener,
}) {
  return NeliveplayerPlatform.instance.create().then((value) {
    String playerId;
    String? textureId;
    if (Platform.isIOS) {
      playerId = value;
    } else if (Platform.isAndroid) {
      List<String> ids = value.split('+');
      playerId = ids.first;
      textureId = ids.last;
    } else {
      playerId = '';
    }

    return NELivePlayer._(playerId,
        textureIdAndroid: textureId,
        onPreparedListener: onPreparedListener,
        onCompletionListener: onCompletionListener,
        onErrorListener: onErrorListener,
        onVideoSizeChangedListener: onVideoSizeChangedListener,
        onReleasedListener: onReleasedListener,
        onLoadStateChangeListener: onLoadStateChangeListener,
        onFirstAudioDisplayListener: onFirstAudioDisplayListener,
        onFirstVideoDisplayListener: onFirstVideoDisplayListener);
  });
}