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) {
final resumePosition = state == FState.paused
? _validResumePosition(_explicitPausePosition)
: null;
if (resumePosition != null) {
FLog.i("$this invoke start from $resumePosition");
} else {
FLog.i("$this invoke start");
}
await _channel.invokeMethod("start", <String, dynamic>{
if (resumePosition != null)
"resumePosition": resumePosition.inMilliseconds,
});
_explicitPausePosition = null;
} else {
FLog.e("$this invoke start invalid state:$state");
return Future.error(StateError("call start on invalid state $state"));
}
}