improved motion photo handling

This commit is contained in:
mertalev
2024-11-16 20:18:22 -05:00
parent d1c7ed5464
commit b0a2a6ac13
5 changed files with 49 additions and 39 deletions
@@ -18,7 +18,13 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final assetIsVideo = ref.watch(
currentAssetProvider.select((asset) => asset != null && asset.isVideo),
);
final showControls = ref.watch(showControlsProvider);
final VideoPlaybackState state =
ref.watch(videoPlaybackValueProvider.select((value) => value.state));
// A timer to hide the controls
final hideTimer = useTimer(
hideTimerDuration,
@@ -27,20 +33,12 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
return;
}
final state = ref.read(videoPlaybackValueProvider).state;
// Do not hide on paused
if (state == VideoPlaybackState.paused) {
return;
}
final asset = ref.read(currentAssetProvider);
if (asset != null && asset.isVideo) {
if (state != VideoPlaybackState.paused && assetIsVideo) {
ref.read(showControlsProvider.notifier).show = false;
}
},
);
final VideoPlaybackState state =
ref.watch(videoPlaybackValueProvider.select((value) => value.state));
final showBuffering = state == VideoPlaybackState.buffering;
/// Shows the controls and starts the timer to hide them
@@ -95,7 +93,7 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
iconColor: Colors.white,
isFinished: state == VideoPlaybackState.completed,
isPlaying: state == VideoPlaybackState.playing,
show: showControls,
show: assetIsVideo && showControls,
onPressed: togglePlay,
),
),
+1 -1
View File
@@ -72,7 +72,7 @@ class MemoryCard extends StatelessWidget {
key: ValueKey(asset.id),
asset: asset,
showControls: false,
placeholder: SizedBox.expand(
image: SizedBox.expand(
child: ImmichImage(
asset,
fit: fit,