From 7d5294f7ef980340248b4b163c62ad3d5c47da02 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:12:34 -0500 Subject: [PATCH] fixed referencing uninitialized orientation --- .../lib/pages/common/native_video_viewer.page.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mobile/lib/pages/common/native_video_viewer.page.dart b/mobile/lib/pages/common/native_video_viewer.page.dart index 173af8f5ab..3974b1d175 100644 --- a/mobile/lib/pages/common/native_video_viewer.page.dart +++ b/mobile/lib/pages/common/native_video_viewer.page.dart @@ -13,6 +13,7 @@ import 'package:immich_mobile/services/api.service.dart'; import 'package:immich_mobile/services/app_settings.service.dart'; import 'package:immich_mobile/services/asset.service.dart'; import 'package:immich_mobile/utils/hooks/interval_hook.dart'; +import 'package:immich_mobile/utils/throttle.dart'; import 'package:immich_mobile/widgets/asset_viewer/custom_video_player_controls.dart'; import 'package:logging/logging.dart'; import 'package:native_video_player/native_video_player.dart'; @@ -71,18 +72,14 @@ class NativeVideoViewerPage extends HookConsumerWidget { if (asset.exifInfo != null) { orientatedWidth = asset.orientatedWidth?.toDouble(); orientatedHeight = asset.orientatedHeight?.toDouble(); - } - - if (orientatedWidth == null && localEntity != null) { + } else if (localEntity != null) { final entity = await localEntity; if (entity != null) { asset.local = entity; orientatedWidth = entity.orientatedWidth.toDouble(); orientatedHeight = entity.orientatedHeight.toDouble(); } - } - - if (orientatedWidth == null) { + } else { final entity = await ref.read(assetServiceProvider).loadExif(asset); orientatedWidth = entity.orientatedWidth?.toDouble(); orientatedHeight = entity.orientatedHeight?.toDouble(); @@ -196,6 +193,8 @@ class NativeVideoViewerPage extends HookConsumerWidget { }); // When the position changes, seek to the position + final seekThrottler = + useThrottler(interval: const Duration(milliseconds: 200)); ref.listen(videoPlayerControlsProvider.select((value) => value.position), (_, position) { final playerController = controller.value; @@ -212,7 +211,7 @@ class NativeVideoViewerPage extends HookConsumerWidget { final int seek = (asset.duration * (position / 100.0)).inSeconds; if (seek != playbackInfo.position) { try { - playerController.seekTo(seek); + seekThrottler.run(() => playerController.seekTo(seek)); } catch (error) { log.severe('Error seeking to position $position: $error'); }