From f8b5371c18fb521c2c08ff7ed84c6e63ff8b4244 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Wed, 25 Feb 2026 18:39:20 -0500 Subject: [PATCH] remove aspect ratio handling --- .../common/native_video_viewer.page.dart | 27 ++------------ .../asset_viewer/video_viewer.widget.dart | 36 ++----------------- 2 files changed, 6 insertions(+), 57 deletions(-) diff --git a/mobile/lib/pages/common/native_video_viewer.page.dart b/mobile/lib/pages/common/native_video_viewer.page.dart index 9cd9f6bd5e..57a800f26b 100644 --- a/mobile/lib/pages/common/native_video_viewer.page.dart +++ b/mobile/lib/pages/common/native_video_viewer.page.dart @@ -16,7 +16,6 @@ import 'package:immich_mobile/providers/asset_viewer/video_player_value_provider import 'package:immich_mobile/providers/cast.provider.dart'; 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/debounce.dart'; import 'package:immich_mobile/utils/hooks/interval_hook.dart'; import 'package:immich_mobile/widgets/asset_viewer/custom_video_player_controls.dart'; @@ -103,19 +102,7 @@ class NativeVideoViewerPage extends HookConsumerWidget { } } - final videoSource = useMemoized>(() => createSource()); - final aspectRatio = useState(asset.aspectRatio); - useMemoized(() async { - if (!context.mounted || aspectRatio.value != null) { - return null; - } - - try { - aspectRatio.value = await ref.read(assetServiceProvider).getAspectRatio(asset); - } catch (error) { - log.severe('Error getting aspect ratio for asset ${asset.fileName}: $error'); - } - }); + final videoSource = useMemoized>(createSource); void checkIfBuffering() { if (!context.mounted) { @@ -361,18 +348,10 @@ class NativeVideoViewerPage extends HookConsumerWidget { // This remains under the video to avoid flickering // For motion videos, this is the image portion of the asset if (!isVideoReady.value || asset.isMotionPhoto) Center(key: ValueKey(asset.id), child: image), - if (aspectRatio.value != null && !isCasting) + if (!isCasting) Visibility.maintain( - key: ValueKey(asset), visible: isVisible.value, - child: Center( - key: ValueKey(asset), - child: AspectRatio( - key: ValueKey(asset), - aspectRatio: aspectRatio.value!, - child: isCurrent ? NativeVideoPlayerView(key: ValueKey(asset), onViewReady: initController) : null, - ), - ), + child: Center(child: isCurrent ? NativeVideoPlayerView(onViewReady: initController) : null), ), if (showControls) const Center(child: CustomVideoPlayerControls()), ], diff --git a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart index 0f6568e8fd..4e8d7cbfcc 100644 --- a/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart +++ b/mobile/lib/presentation/widgets/asset_viewer/video_viewer.widget.dart @@ -142,20 +142,7 @@ class NativeVideoViewer extends HookConsumerWidget { } } - final videoSource = useMemoized>(() => createSource()); - final aspectRatio = useState(null); - - useMemoized(() async { - if (!context.mounted || aspectRatio.value != null) { - return null; - } - - try { - aspectRatio.value = await ref.read(assetServiceProvider).getAspectRatio(asset); - } catch (error) { - log.severe('Error getting aspect ratio for asset ${asset.name}: $error'); - } - }, [asset.heroTag]); + final videoSource = useMemoized>(createSource); void checkIfBuffering() { if (!context.mounted) { @@ -320,20 +307,6 @@ class NativeVideoViewer extends HookConsumerWidget { Timer(const Duration(milliseconds: 200), checkIfBuffering); } - Size? videoContextSize(double? videoAspectRatio, BuildContext? context) { - Size? videoContextSize; - if (videoAspectRatio == null || context == null) { - return null; - } - final contextAspectRatio = context.width / context.height; - if (videoAspectRatio > contextAspectRatio) { - videoContextSize = Size(context.width, context.width / aspectRatio.value!); - } else { - videoContextSize = Size(context.height * aspectRatio.value!, context.height); - } - return videoContextSize; - } - ref.listen(currentAssetNotifier, (_, value) { final playerController = controller.value; if (playerController != null && value != asset) { @@ -421,19 +394,16 @@ class NativeVideoViewer extends HookConsumerWidget { children: [ // Hide thumbnail once video is visible to avoid it showing in background when zooming out on video. if (!isVisible.value || controller.value == null) Center(key: ValueKey(asset.heroTag), child: image), - if (aspectRatio.value != null && !isCasting && isCurrent) + if (!isCasting) Visibility.maintain( - key: ValueKey(asset), visible: isVisible.value, child: PhotoView.customChild( - key: ValueKey(asset), enableRotation: false, disableScaleGestures: disableScaleGestures, // Transparent to avoid a black flash when viewer becomes visible but video isn't loaded yet. backgroundDecoration: const BoxDecoration(color: Colors.transparent), scaleStateChangedCallback: (state) => scaleStateNotifier?.value = state, - childSize: videoContextSize(aspectRatio.value, context), - child: NativeVideoPlayerView(key: ValueKey(asset), onViewReady: initController), + child: isCurrent ? NativeVideoPlayerView(onViewReady: initController) : null, ), ), if (showControls) const Center(child: VideoViewerControls()),