playAtIndex method

Future<void> playAtIndex(
  1. int index
)

Play at Specific Index

Safely clamps out-of-range calls (ignored).

Implementation

Future<void> playAtIndex(int index) async {
  if (_currentPlaylist.isEmpty || index < 0 || index >= _currentPlaylist.length) return;

  _index = index;
  _persistIfDefault();

  await play(_currentPlaylist[_index]);
}