Skip to content

armgit / ente

Public Imported from GitHub
0

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

Hide seekbar and play/pause button for videos shown in memories & long press to play/pause video

AmanRajSinghMourya3cea8e8a9021
diff --git a/mobile/lib/ui/viewer/file/video_widget.dart b/mobile/lib/ui/viewer/file/video_widget.dart
index 5cb861d56c..2e6f9a672d 100644
--- a/mobile/lib/ui/viewer/file/video_widget.dart
+++ b/mobile/lib/ui/viewer/file/video_widget.dart
@@ -24,12 +24,15 @@ class VideoWidget extends StatefulWidget {
final EnteFile file;
final String? tagPrefix;
final Function(bool)? playbackCallback;
- final Function(bool, int)? onFileLoad;
+ final Function(bool, int)? onFinalFileLoad;
+ final bool isFromMemories;
+
const VideoWidget(
this.file, {
this.tagPrefix,
this.playbackCallback,
- this.onFileLoad,
+ this.onFinalFileLoad,
+ this.isFromMemories = false,
super.key,
});
@@ -153,6 +156,7 @@ class _VideoWidgetState extends State<VideoWidget> {
playbackCallback: widget.playbackCallback,
playlistData: playlistData,
selectedPreview: playPreview,
+ isFromMemories: widget.isFromMemories,
onStreamChange: () {
setState(() {
selectPreviewForPlay = !selectPreviewForPlay;
@@ -166,7 +170,7 @@ class _VideoWidgetState extends State<VideoWidget> {
);
});
},
- onFileLoad: widget.onFileLoad,
+ onFinalFileLoad: widget.onFinalFileLoad,
);
}
return VideoWidgetMediaKitNew(
@@ -176,6 +180,7 @@ class _VideoWidgetState extends State<VideoWidget> {
playbackCallback: widget.playbackCallback,
preview: playlistData?.preview,
selectedPreview: playPreview,
+ isFromMemories: widget.isFromMemories,
onStreamChange: () {
setState(() {
selectPreviewForPlay = !selectPreviewForPlay;
@@ -189,7 +194,7 @@ class _VideoWidgetState extends State<VideoWidget> {
);
});
},
- onFileLoad: widget.onFileLoad,
+ onFinalFileLoad: widget.onFinalFileLoad,
);
}
}
diff --git a/mobile/lib/ui/viewer/file/video_widget_media_kit_common.dart b/mobile/lib/ui/viewer/file/video_widget_media_kit_common.dart
index af7f048562..34234e2259 100644
--- a/mobile/lib/ui/viewer/file/video_widget_media_kit_common.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_media_kit_common.dart
@@ -100,6 +100,7 @@ class _VideoWidgetState extends State<VideoWidget> {
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
+ if (widget.isFromMemories) return;
showControlsNotifier.value = !showControlsNotifier.value;
if (widget.playbackCallback != null) {
widget.playbackCallback!(
@@ -107,48 +108,62 @@ class _VideoWidgetState extends State<VideoWidget> {
);
}
},
+ onLongPress: () {
+ if (widget.isFromMemories) {
+ widget.controller.player.stop();
+ }
+ },
+ onLongPressUp: () {
+ if (widget.isFromMemories) {
+ widget.controller.player.play();
+ }
+ },
child: Container(
constraints: const BoxConstraints.expand(),
),
),
- IgnorePointer(
- ignoring: !value,
- child: PlayPauseButtonMediaKit(widget.controller),
- ),
- Positioned(
- bottom: verticalMargin,
- right: 0,
- left: 0,
- child: IgnorePointer(
- ignoring: !value,
- child: SafeArea(
- top: false,
- left: false,
- right: false,
- child: Padding(
- padding: EdgeInsets.only(
- bottom: widget.isFromMemories ? 32 : 0,
- ),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- VideoStreamChangeWidget(
- showControls: value,
- file: widget.file,
- isPreviewPlayer: widget.isPreviewPlayer,
- onStreamChange: widget.onStreamChange,
- ),
- SeekBarAndDuration(
- controller: widget.controller,
- isSeekingNotifier: _isSeekingNotifier,
- file: widget.file,
+ widget.isFromMemories
+ ? const SizedBox.shrink()
+ : IgnorePointer(
+ ignoring: !value,
+ child: PlayPauseButtonMediaKit(widget.controller),
+ ),
+ widget.isFromMemories
+ ? const SizedBox.shrink()
+ : Positioned(
+ bottom: verticalMargin,
+ right: 0,
+ left: 0,
+ child: IgnorePointer(
+ ignoring: !value,
+ child: SafeArea(
+ top: false,
+ left: false,
+ right: false,
+ child: Padding(
+ padding: EdgeInsets.only(
+ bottom: widget.isFromMemories ? 32 : 0,
+ ),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ VideoStreamChangeWidget(
+ showControls: value,
+ file: widget.file,
+ isPreviewPlayer: widget.isPreviewPlayer,
+ onStreamChange: widget.onStreamChange,
+ ),
+ SeekBarAndDuration(
+ controller: widget.controller,
+ isSeekingNotifier: _isSeekingNotifier,
+ file: widget.file,
+ ),
+ ],
+ ),
),
- ],
+ ),
),
),
- ),
- ),
- ),
],
),
);
diff --git a/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart b/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
index b16982a016..f49763f20f 100644
--- a/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_media_kit_new.dart
@@ -34,7 +34,7 @@ class VideoWidgetMediaKitNew extends StatefulWidget {
final void Function() onStreamChange;
final File? preview;
final bool selectedPreview;
- final Function(bool, int)? onFileLoad;
+ final Function(bool, int)? onFinalFileLoad;
const VideoWidgetMediaKitNew(
this.file, {
@@ -44,7 +44,7 @@ class VideoWidgetMediaKitNew extends StatefulWidget {
required this.onStreamChange,
this.preview,
required this.selectedPreview,
- this.onFileLoad,
+ this.onFinalFileLoad,
super.key,
});
@@ -263,7 +263,7 @@ class _VideoWidgetMediaKitNewState extends State<VideoWidgetMediaKitNew>
player.open(Media(url), play: _isAppInFG);
});
final duration = controller!.player.state.duration.inSeconds;
- widget.onFileLoad?.call(true, duration);
+ widget.onFinalFileLoad?.call(true, duration);
}
}
}
diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dart
index 93243a8a7a..f4971a3a4d 100644
--- a/mobile/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart
@@ -45,7 +45,7 @@ class VideoWidgetNative extends StatefulWidget {
final void Function()? onStreamChange;
final PlaylistData? playlistData;
final bool selectedPreview;
- final Function(bool, int)? onFileLoad;
+ final Function(bool, int)? onFinalFileLoad;
const VideoWidgetNative(
this.file, {
@@ -55,7 +55,7 @@ class VideoWidgetNative extends StatefulWidget {
required this.onStreamChange,
super.key,
this.playlistData,
- this.onFileLoad,
+ this.onFinalFileLoad,
required this.selectedPreview,
});
@@ -285,12 +285,23 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
+ if (widget.isFromMemories) return;
_showControls.value = !_showControls.value;
if (widget.playbackCallback != null) {
widget.playbackCallback!(!_showControls.value);
}
_elTooltipController.hide();
},
+ onLongPress: () {
+ if (widget.isFromMemories) {
+ _controller?.pause();
+ }
+ },
+ onLongPressUp: () {
+ if (widget.isFromMemories) {
+ _controller?.play();
+ }
+ },
child: Container(
constraints: const BoxConstraints.expand(),
),
@@ -314,32 +325,38 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
),
)
: const SizedBox.shrink(),
- Positioned.fill(
- child: Center(
- child: ValueListenableBuilder(
- builder: (BuildContext context, bool value, _) {
- return value
- ? ValueListenableBuilder(
- builder: (context, bool value, _) {
- return AnimatedOpacity(
- duration:
- const Duration(milliseconds: 200),
- opacity: value ? 1 : 0,
- curve: Curves.easeInOutQuad,
- child: IgnorePointer(
- ignoring: !value,
- child: PlayPauseButton(_controller),
- ),
- );
- },
- valueListenable: _showControls,
- )
- : const SizedBox();
- },
- valueListenable: _isPlaybackReady,
- ),
- ),
- ),
+ widget.isFromMemories
+ ? const SizedBox.shrink()
+ : Positioned.fill(
+ child: Center(
+ child: ValueListenableBuilder(
+ builder:
+ (BuildContext context, bool value, _) {
+ return value
+ ? ValueListenableBuilder(
+ builder: (context, bool value, _) {
+ return AnimatedOpacity(
+ duration: const Duration(
+ milliseconds: 200,
+ ),
+ opacity: value ? 1 : 0,
+ curve: Curves.easeInOutQuad,
+ child: IgnorePointer(
+ ignoring: !value,
+ child: PlayPauseButton(
+ _controller,
+ ),
+ ),
+ );
+ },
+ valueListenable: _showControls,
+ )
+ : const SizedBox();
+ },
+ valueListenable: _isPlaybackReady,
+ ),
+ ),
+ ),
Positioned(
bottom: verticalMargin,
right: 0,
@@ -377,7 +394,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
valueListenable: _isPlaybackReady,
builder:
(BuildContext context, bool value, _) {
- return value
+ return value && !widget.isFromMemories
? _SeekBarAndDuration(
controller: _controller,
duration: duration,
@@ -509,7 +526,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
if (_isPlaybackReady.value) return;
await _controller!.play();
final durationInSeconds = durationToSeconds(duration) ?? 0;
- widget.onFileLoad?.call(true, durationInSeconds);
+ widget.onFinalFileLoad?.call(true, durationInSeconds);
unawaited(_controller!.setVolume(1));
_isPlaybackReady.value = true;
}
@@ -711,11 +728,7 @@ class _SeekBarAndDuration extends StatelessWidget {
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: showControls,
- builder: (
- BuildContext context,
- bool value,
- _,
- ) {
+ builder: (BuildContext context, bool value, _) {
return AnimatedOpacity(
duration: const Duration(
milliseconds: 200,