Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Do not hide controls when seeking + Hide controls after seeking + do not surface controls when video starts over when playing in loop:

ashilknf7345102a2ea
diff --git a/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart b/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
index 886156b899..48f1dc6be6 100644
--- a/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
+++ b/mobile/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
@@ -9,7 +9,8 @@ import "package:photos/utils/debouncer.dart";
class SeekBar extends StatefulWidget {
final NativeVideoPlayerController controller;
final int? duration;
- const SeekBar(this.controller, this.duration, {super.key});
+ final ValueNotifier<bool> isSeeking;
+ const SeekBar(this.controller, this.duration, this.isSeeking, {super.key});
@override
State<SeekBar> createState() => _SeekBarState();
@@ -73,6 +74,9 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
min: 0.0,
max: 1.0,
value: _animationController.value,
+ onChangeStart: (value) {
+ widget.isSeeking.value = true;
+ },
onChanged: (value) {
setState(() {
_animationController.value = value;
@@ -85,6 +89,7 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
_animationController.value = value;
});
_seekTo(value);
+ widget.isSeeking.value = false;
},
allowedInteraction: SliderInteraction.tapAndSlide,
),
diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dart
index 5bf39c762c..1b53e5c3a8 100644
--- a/mobile/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart
@@ -62,6 +62,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
bool _shouldClearCache = false;
bool _isCompletelyVisible = false;
final _showControls = ValueNotifier(true);
+ final _isSeeking = ValueNotifier(false);
@override
void initState() {
@@ -143,6 +144,8 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
.removeListener(_onPlaybackStatusChanged);
_isPlaybackReady.dispose();
_showControls.dispose();
+ _isSeeking.removeListener(_isSeekingListener);
+ _isSeeking.dispose();
super.dispose();
}
@@ -313,6 +316,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
_durationToSeconds(
duration,
),
+ _isSeeking,
),
),
Text(
@@ -391,6 +395,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
controller.onPlaybackEnded.addListener(_onPlaybackEnded);
controller.onPlaybackReady.addListener(_onPlaybackReady);
controller.onPlaybackStatusChanged.addListener(_onPlaybackStatusChanged);
+ _isSeeking.addListener(_isSeekingListener);
final videoSource = await VideoSource.init(
path: _filePath!,
@@ -402,7 +407,23 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
}
+ void _isSeekingListener() {
+ if (!_isSeeking.value &&
+ _controller?.playbackInfo?.status == PlaybackStatus.playing) {
+ Future.delayed(const Duration(milliseconds: 1500), () {
+ if (mounted) {
+ _showControls.value = false;
+ }
+ });
+ }
+ }
+
+ ///Need to not execute this if the status change is coming from a video getting
+ ///played in loop.
void _onPlaybackStatusChanged() {
+ if (_isSeeking.value || _controller?.playbackInfo?.positionFraction == 1) {
+ return;
+ }
if (_controller!.playbackInfo?.status == PlaybackStatus.playing) {
if (widget.playbackCallback != null && mounted) {
Future.delayed(const Duration(milliseconds: 1500), () {