start method

Future<void> start ()

change player's state to FijkState.started

throw StateError if call this method on invalid state. see fijkstate zh or fijkstate en for details

Implementation

Future<void> start() async {
  await _nativeSetup.future;
  if (state == FijkState.initialized) {
    _callId += 1;
    int cid = _callId;
    FijkLog.i("$this invoke prepareAsync and start #$cid");
    await setOption(FijkOption.playerCategory, "start-on-prepared", 1);
    await _channel.invokeMethod("prepareAsync");
    FijkLog.i("$this invoke prepareAsync and start #$cid -> done");
  } else if (state == FijkState.asyncPreparing ||
      state == FijkState.prepared ||
      state == FijkState.paused ||
      state == FijkState.started ||
      value.state == FijkState.completed) {
    FijkLog.i("$this invoke start");
    await _channel.invokeMethod("start");
  } else {
    FijkLog.e("$this invoke start invalid state:$state");
    return Future.error(StateError("call start on invalid state $state"));
  }
}