Compare commits

...

2 Commits

Author SHA1 Message Date
mertalev
687f43c976 update commit 2026-02-25 18:40:25 -05:00
mertalev
f8b5371c18 remove aspect ratio handling 2026-02-25 18:39:20 -05:00
4 changed files with 9 additions and 60 deletions

View File

@@ -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<Future<VideoSource?>>(() => createSource());
final aspectRatio = useState<double?>(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<Future<VideoSource?>>(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()),
],

View File

@@ -142,20 +142,7 @@ class NativeVideoViewer extends HookConsumerWidget {
}
}
final videoSource = useMemoized<Future<VideoSource?>>(() => createSource());
final aspectRatio = useState<double?>(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<Future<VideoSource?>>(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()),

View File

@@ -1241,8 +1241,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: e132bc3
resolved-ref: e132bc3ecc6a6d8fc2089d96f849c8a13129500e
ref: "4d39883"
resolved-ref: "4d39883a7582d42e6ca88dcf4b0320f20efc2562"
url: "https://github.com/immich-app/native_video_player"
source: git
version: "1.3.1"

View File

@@ -57,7 +57,7 @@ dependencies:
native_video_player:
git:
url: https://github.com/immich-app/native_video_player
ref: 'e132bc3'
ref: '4d39883'
network_info_plus: ^6.1.3
octo_image: ^2.1.0
openapi: