setPlaybackSpeed method
Sets the playback speed.
speed
- the rate at which VLC should play media.
For reference:
2.0 is double speed.
1.0 is normal speed.
0.5 is half speed.
Implementation
Future<void> setPlaybackSpeed(double speed) async {
if (speed < 0) {
throw ArgumentError.value(
speed,
'Negative playback speeds are not supported.',
);
} else if (speed == 0) {
throw ArgumentError.value(
speed,
'Zero playback speed is not supported. Consider using [pause].',
);
}
_throwIfNotInitialized('setPlaybackSpeed');
// Setting the playback speed on iOS will trigger the video to play. We
// prevent this from happening by not applying the playback speed until
// the video is manually played from Flutter.
if (!value.isPlaying) return;
value = value.copyWith(playbackSpeed: speed);
await vlcPlayerPlatform.setPlaybackSpeed(
_viewId,
value.playbackSpeed,
);
}