setSpeed method
Set playback speed of video. Allows to set speed value between 0 and 2.
Implementation
Future<void> setSpeed(double speed) async {
if (speed <= 0 || speed > 2) {
BetterPlayerUtils.log("Speed must be between 0 and 2");
throw ArgumentError("Speed must be between 0 and 2");
}
if (videoPlayerController == null) {
BetterPlayerUtils.log("The data source has not been initialized");
throw StateError("The data source has not been initialized");
}
await videoPlayerController?.setSpeed(speed);
_postEvent(
BetterPlayerEvent(
BetterPlayerEventType.setSpeed,
parameters: <String, dynamic>{
_speedParameter: speed,
},
),
);
}