play method

  1. @override
Future<RadioPlayerState> play({
  1. int? index,
})
override

Plays the current source, or source index if given.

Implementation

@override
Future<RadioPlayerState> play({int? index}) {
  calls.add(index == null ? 'play' : 'play(index: $index)');
  if (_state.sources.isEmpty) return _reply(_state);
  if (index != null) {
    if (index < 0 || index >= _state.sources.length) {
      return Future.error(RangeError.index(index, _state.sources));
    }
    if (index != _state.currentIndex) _switchTo(index);
  }
  _startPlaying();
  return _reply(_state);
}