play method

  1. @override
Future<void> play({
  1. bool synchronized = true,
})
override

Starts playing the Player.

Implementation

@override
Future<void> play({bool synchronized = true}) {
  Future<void> function() async {
    if (disposed) {
      throw AssertionError('[Player] has been disposed');
    }
    await waitForPlayerInitialization;
    await waitForVideoControllerInitializationIfAttached;

    state = state.copyWith(playing: true);
    if (!playingController.isClosed) {
      playingController.add(true);
    }

    final name = 'pause'.toNativeUtf8();
    final value = calloc<Uint8>();
    mpv.mpv_get_property(
      ctx,
      name.cast(),
      generated.mpv_format.MPV_FORMAT_FLAG,
      value.cast(),
    );
    if (value.value == 1) {
      await playOrPause(
        notify: false,
        synchronized: false,
      );
    }
    calloc.free(name);
    calloc.free(value);
  }

  if (synchronized) {
    return lock.synchronized(function);
  } else {
    return function();
  }
}