skipToIndex method

Future<bool> skipToIndex(
  1. int index
)

Skips to a specific index in the playlist.

Returns true if successful, false if the index is out of bounds.

Implementation

Future<bool> skipToIndex(int index) async {
  final playlist = _playlist;
  if (playlist == null) return false;

  if (!playlist.moveToIndex(index)) {
    return false;
  }

  final source = playlist.currentSource;
  if (source == null) return false;

  if (source is UriAudioSource) {
    return await startPlayback(source.uri.toString());
  }

  return false;
}