togglePlaybackSpeed method

Future<void> togglePlaybackSpeed()

Implementation

Future<void> togglePlaybackSpeed() async {
  List<double> allowedSpeeds = [0.25, 0.5, 0.75, 1.0, 1.25, 1.50, 1.75, 2.0];
  if (allowedSpeeds.indexOf(_playbackSpeed.value) <
      allowedSpeeds.length - 1) {
    setPlaybackSpeed(
        allowedSpeeds[allowedSpeeds.indexOf(_playbackSpeed.value) + 1]);
  } else {
    setPlaybackSpeed(allowedSpeeds[0]);
  }
}