Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: buffering indicator

Prateek Sunal38ae9e2b19fb
diff --git a/mobile/lib/ui/viewer/file/video_control.dart b/mobile/lib/ui/viewer/file/video_control.dart
index e89e583dd9..d662819003 100644
--- a/mobile/lib/ui/viewer/file/video_control.dart
+++ b/mobile/lib/ui/viewer/file/video_control.dart
@@ -33,6 +33,8 @@ class _VideoControlsState extends State<VideoControls> {
Timer? _showAfterExpandCollapseTimer;
bool _dragging = false;
bool _displayTapped = false;
+ Timer? _bufferingDisplayTimer;
+ bool _displayBufferingIndicator = false;
final barHeight = 120.0;
final marginSize = 5.0;
@@ -40,6 +42,13 @@ class _VideoControlsState extends State<VideoControls> {
late VideoPlayerController controller;
ChewieController? chewieController;
+ void _bufferingTimerTimeout() {
+ _displayBufferingIndicator = true;
+ if (mounted) {
+ setState(() {});
+ }
+ }
+
@override
Widget build(BuildContext context) {
if (_latestValue!.hasError) {
@@ -68,8 +77,9 @@ class _VideoControlsState extends State<VideoControls> {
child: Stack(
children: <Widget>[
if (_latestValue != null &&
- !_latestValue!.isPlaying &&
- _latestValue!.isBuffering)
+ !_latestValue!.isPlaying &&
+ _latestValue!.isBuffering ||
+ _displayBufferingIndicator)
const Align(
alignment: Alignment.center,
child: Center(
@@ -253,6 +263,21 @@ class _VideoControlsState extends State<VideoControls> {
}
void _updateState() {
+ // display the progress bar indicator only after the buffering delay if it has been set
+ if (chewieController?.progressIndicatorDelay != null) {
+ if (controller.value.isBuffering) {
+ _bufferingDisplayTimer ??= Timer(
+ chewieController!.progressIndicatorDelay!,
+ _bufferingTimerTimeout,
+ );
+ } else {
+ _bufferingDisplayTimer?.cancel();
+ _bufferingDisplayTimer = null;
+ _displayBufferingIndicator = false;
+ }
+ } else {
+ _displayBufferingIndicator = controller.value.isBuffering;
+ }
setState(() {
_latestValue = controller.value;
});