Skip to content

Commit

Permalink
Added a playbackDelayFactor to the video viewer to resolve an issue i…
Browse files Browse the repository at this point in the history
…n memories.

Also adjusted the scale of the memory preview image to match the ratio of the video. This still appears to jump because the video preview doesn't seem to be the first frame for some reason :\
  • Loading branch information
tomgquest committed Jan 16, 2025
1 parent 792e11b commit c8c4bde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions mobile/lib/pages/common/native_video_viewer.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import 'package:wakelock_plus/wakelock_plus.dart';
class NativeVideoViewerPage extends HookConsumerWidget {
final Asset asset;
final bool showControls;
final int playbackDelayFactor;
final Widget image;

const NativeVideoViewerPage({
super.key,
required this.asset,
required this.image,
this.showControls = true,
this.playbackDelayFactor = 1,
});

@override
Expand Down Expand Up @@ -317,12 +319,16 @@ class NativeVideoViewerPage extends HookConsumerWidget {
}

// Delay the video playback to avoid a stutter in the swipe animation
// Note, in some circumstances a longer delay is needed (eg: memories),
// the playbackDelayFactor can be used for this
// This delay seems like a hacky way to resolve underlying bugs in video
// playback, but other resolutions failed thus far
Timer(
Platform.isIOS
? const Duration(milliseconds: 300)
? Duration(milliseconds: 300 * playbackDelayFactor)
: imageToVideo
? const Duration(milliseconds: 200)
: const Duration(milliseconds: 400), () {
? Duration(milliseconds: 200 * playbackDelayFactor)
: Duration(milliseconds: 400 * playbackDelayFactor), () {
if (!context.mounted) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion mobile/lib/widgets/memories/memory_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ class MemoryCard extends StatelessWidget {
key: ValueKey(asset.id),
asset: asset,
showControls: false,
playbackDelayFactor: 2,
image: ImmichImage(
asset,
width: context.width,
height: context.height,
fit: fit,
fit: BoxFit.contain,
),
),
),
Expand Down

0 comments on commit c8c4bde

Please sign in to comment.