Skip to content

Commit ecea260

Browse files
committed
Workaround loading spinner after video finished not disappearing on android
1 parent a05a72d commit ecea260

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

lib/src/cupertino/cupertino_controls.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,19 @@ class _CupertinoControlsState extends State<CupertinoControls>
818818
// -> Check if we actually buffer, as android has a bug preventing to
819819
// get the correct buffering state from this single bool.
820820
final VideoPlayerValue value = controller.value;
821-
final int buffer = value.buffered.lastOrNull?.end.inMilliseconds ?? -1;
821+
822822
final int position = value.position.inMilliseconds;
823823

824-
buffering = position >= buffer;
824+
// Special case, if the video is finished, we don't want to show the
825+
// buffering indicator anymore
826+
if (position >= value.duration.inMilliseconds) {
827+
buffering = false;
828+
} else {
829+
final int buffer =
830+
value.buffered.lastOrNull?.end.inMilliseconds ?? -1;
831+
832+
buffering = position >= buffer;
833+
}
825834
} else {
826835
// -> No buffering
827836
buffering = false;

lib/src/material/material_controls.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,19 @@ class _MaterialControlsState extends State<MaterialControls>
653653
// -> Check if we actually buffer, as android has a bug preventing to
654654
// get the correct buffering state from this single bool.
655655
final VideoPlayerValue value = controller.value;
656-
final int buffer = value.buffered.lastOrNull?.end.inMilliseconds ?? -1;
656+
657657
final int position = value.position.inMilliseconds;
658658

659-
buffering = position >= buffer;
659+
// Special case, if the video is finished, we don't want to show the
660+
// buffering indicator anymore
661+
if (position >= value.duration.inMilliseconds) {
662+
buffering = false;
663+
} else {
664+
final int buffer =
665+
value.buffered.lastOrNull?.end.inMilliseconds ?? -1;
666+
667+
buffering = position >= buffer;
668+
}
660669
} else {
661670
// -> No buffering
662671
buffering = false;

lib/src/material/material_desktop_controls.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,19 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
589589
// -> Check if we actually buffer, as android has a bug preventing to
590590
// get the correct buffering state from this single bool.
591591
final VideoPlayerValue value = controller.value;
592-
final int buffer = value.buffered.lastOrNull?.end.inMilliseconds ?? -1;
592+
593593
final int position = value.position.inMilliseconds;
594594

595-
buffering = position >= buffer;
595+
// Special case, if the video is finished, we don't want to show the
596+
// buffering indicator anymore
597+
if (position >= value.duration.inMilliseconds) {
598+
buffering = false;
599+
} else {
600+
final int buffer =
601+
value.buffered.lastOrNull?.end.inMilliseconds ?? -1;
602+
603+
buffering = position >= buffer;
604+
}
596605
} else {
597606
// -> No buffering
598607
buffering = false;

0 commit comments

Comments
 (0)