previous method

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

Jumps to previous Media in the Player's playlist.

Implementation

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

    // Do nothing if currently present at the first or last index & playlist mode is [PlaylistMode.none] or [PlaylistMode.single].
    if ([
          PlaylistMode.none,
          PlaylistMode.single,
        ].contains(state.playlistMode) &&
        state.playlist.index == 0) {
      return;
    }

    await play(synchronized: false);
    final command = 'playlist-prev'.toNativeUtf8();
    mpv.mpv_command_string(
      ctx,
      command.cast(),
    );
    calloc.free(command);
  }

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