Skip to content

Commit b79735a

Browse files
committed
fix video speed not changing if it was changed during buffering
1 parent 46335e6 commit b79735a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/src/widgets/video/loli_controls.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class _LoliControlsState extends State<LoliControls> {
139139
void _dispose() {
140140
controller.removeListener(_updateState);
141141

142-
if (_latestValue.playbackSpeed != 1) {
143-
controller.setPlaybackSpeed(1);
144-
}
142+
controller.setPlaybackSpeed(1);
145143
doubleTapped = false;
146144
holdingDown = false;
147145
speedSetManually = false;
@@ -531,7 +529,7 @@ class _LoliControlsState extends State<LoliControls> {
531529
if (chosenSpeed != null) {
532530
await controller.setPlaybackSpeed(chosenSpeed);
533531
setState(() {
534-
speedSetManually = true;
532+
speedSetManually = chosenSpeed != 1;
535533
});
536534
}
537535

@@ -716,6 +714,11 @@ class _LoliControlsState extends State<LoliControls> {
716714
if (holdingDown && pointerCount != 1) {
717715
onHitAreaLongPressUp();
718716
}
717+
if (pointerCount == 0 && !speedSetManually) {
718+
// reset speed when there are no fingers detected and it wasn't set through dialog
719+
// required because video controller wrongly reports that speed is reset and speed may not reset properly if it was changed during buffering
720+
controller.setPlaybackSpeed(1);
721+
}
719722
},
720723
);
721724
}
@@ -1040,10 +1043,8 @@ class _PlaybackSpeedDialogState extends State<_PlaybackSpeedDialog> {
10401043

10411044
Future<void> resetValue() async {
10421045
selectedIndex.value = widget.speeds.indexOf(1);
1043-
await controller.animateToPage(
1046+
controller.jumpToPage(
10441047
selectedIndex.value,
1045-
duration: const Duration(milliseconds: 200),
1046-
curve: Curves.easeInOut,
10471048
);
10481049
confirmValue();
10491050
}

0 commit comments

Comments
 (0)