prepare method

Future<int> prepare({
  1. int position = 0,
  2. SeekFlag flags = const SeekFlag(SeekFlag.defaultFlags),
  3. Future<bool> callback()?,
})

Load the media from position in milliseconds and decode the first frame, then state will be PlaybackState.paused. If error occurs, will be PlaybackState.stopped. Return the result position, or a negative value if failed. https://github.com/wang-bin/mdk-sdk/wiki/Player-APIs#void-prepareint64_t-startposition--0-functionboolint64_t-position-bool-boost-cb--nullptr-seekflag-flags--seekflagfromstart

Return 0: if mediaInfo.streams == 0, invalid media. otherwise success -1: already loading or loaded -4: requested position out of range -10: internal error

Implementation

Future<int> prepare(
    {int position = 0,
    SeekFlag flags = const SeekFlag(SeekFlag.defaultFlags),
    Future<bool> Function()? callback}) async {
  _prepared = Completer<int>();
  Libfvp.registerType(nativeHandle, 3, true);
  _prepareCb = callback;
  if (!Libfvp.prepare(nativeHandle, position, flags.rawValue,
      NativeApi.postCObject.cast(), _receivePort.sendPort.nativePort)) {
    _prepared.complete(-10);
  }
  return _prepared.future;
}