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;
  FijkLog.i("$this invoke release #$cid");
  if (isPlayable()) await stop();
  _setValue(value.copyWith(state: FijkState.end));
  await _nativeEventSubscription?.cancel();
  _nativeEventSubscription = null;
  _allInstance.remove(_playerId);
  await FijkPlugin._releasePlayer(_playerId).then((_) {
    FijkLog.i("$this invoke release #$cid -> done");
  });
}