dispose method

void dispose()

Release resources

Implementation

void dispose() async {
  if (_pp == nullptr) {
    return;
  }
  // await: ensure no player ref in fvp plugin before mdkPlayerAPI_delete() in dart
  await updateTexture(width: -1);
  state = PlaybackState.stopped;
  Libfvp.unregisterPort(nativeHandle);
  onEvent(null);
  onStateChanged(null);
  onMediaStatus(null);

  _receivePort.close();

  Libmdk.instance.mdkPlayerAPI_delete(_pp);
  calloc.free(_pp);
  _pp = nullptr;
}