start method
change player's state to FState.started
throw StateError if call this method on invalid state. see fstate zh for details
Implementation
Future<void> start() async {
await _nativeSetup.future;
if (state == FState.initialized) {
_callId += 1;
int cid = _callId;
FLog.i("$this invoke prepareAsync and start #$cid");
await setOption(FOption.playerCategory, "start-on-prepared", 1);
await _channel.invokeMethod("prepareAsync");
FLog.i("$this invoke prepareAsync and start #$cid -> done");
} else if (state == FState.asyncPreparing ||
state == FState.prepared ||
state == FState.paused ||
state == FState.started ||
value.state == FState.completed) {
FLog.i("$this invoke start");
await _channel.invokeMethod("start");
} else {
FLog.e("$this invoke start invalid state:$state");
return Future.error(StateError("call start on invalid state $state"));
}
}