Skip to content

Commit

Permalink
delay video initialization to avoid placeholder flicker
Browse files Browse the repository at this point in the history
  • Loading branch information
mertalev committed Dec 4, 2024
1 parent 71660ab commit b76f81b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mobile/lib/pages/common/native_video_viewer.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ class NativeVideoViewerPage extends HookConsumerWidget {
return;
}

if (newControls.restarted) {
debugPrint('!!!!!!!!!!!!newControls.restarted!!!!!!!!!!!!!!');
}

final oldSeek = (oldControls?.position ?? 0) ~/ 1;
final newSeek = newControls.position ~/ 1;
if (oldSeek != newSeek || newControls.restarted) {
Expand Down Expand Up @@ -338,7 +334,13 @@ class NativeVideoViewerPage extends HookConsumerWidget {
}

// Delay the video playback to avoid a stutter in the swipe animation
Timer(const Duration(milliseconds: 300), () {
Timer(
Platform.isIOS
? const Duration(milliseconds: 300)
// On Android, the placeholder of the first opened video
// can briefly be seen and cause a flicker effect unless the animation is delayed longer
// - probably a bug in PhotoViewGallery's animation handling
: const Duration(milliseconds: 500), () {
if (!context.mounted) {
return;
}
Expand Down

0 comments on commit b76f81b

Please sign in to comment.