release method

Future<void> release()

Release native player. Release memory and resource

Implementation

Future<void> release() async {
  await _nativeSetup.future;
  _callId += 1;
  int cid = _callId;
  FLog.i("$this invoke release #$cid");
  if (isPlayable()) await stop();
  _setValue(value.copyWith(state: FState.end));
  await _nativeEventSubscription?.cancel();
  _nativeEventSubscription = null;
  _allInstance.remove(_playerId);
  await FPlugin._releasePlayer(_playerId).then((_) {
    FLog.i("$this invoke release #$cid -> done");
  });
}