setShuffle method

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

Enables or disables shuffle for Player. Default is false.

Implementation

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

    if (shuffle == isShuffleEnabled) {
      return;
    }
    isShuffleEnabled = shuffle;

    await _command(
      [
        shuffle ? 'playlist-shuffle' : 'playlist-unshuffle',
      ],
    );
  }

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