mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fixed referencing uninitialized orientation
This commit is contained in:
parent
973b146d06
commit
7d5294f7ef
1 changed files with 6 additions and 7 deletions
|
@ -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/app_settings.service.dart';
|
||||||
import 'package:immich_mobile/services/asset.service.dart';
|
import 'package:immich_mobile/services/asset.service.dart';
|
||||||
import 'package:immich_mobile/utils/hooks/interval_hook.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:immich_mobile/widgets/asset_viewer/custom_video_player_controls.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:native_video_player/native_video_player.dart';
|
import 'package:native_video_player/native_video_player.dart';
|
||||||
|
@ -71,18 +72,14 @@ class NativeVideoViewerPage extends HookConsumerWidget {
|
||||||
if (asset.exifInfo != null) {
|
if (asset.exifInfo != null) {
|
||||||
orientatedWidth = asset.orientatedWidth?.toDouble();
|
orientatedWidth = asset.orientatedWidth?.toDouble();
|
||||||
orientatedHeight = asset.orientatedHeight?.toDouble();
|
orientatedHeight = asset.orientatedHeight?.toDouble();
|
||||||
}
|
} else if (localEntity != null) {
|
||||||
|
|
||||||
if (orientatedWidth == null && localEntity != null) {
|
|
||||||
final entity = await localEntity;
|
final entity = await localEntity;
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
asset.local = entity;
|
asset.local = entity;
|
||||||
orientatedWidth = entity.orientatedWidth.toDouble();
|
orientatedWidth = entity.orientatedWidth.toDouble();
|
||||||
orientatedHeight = entity.orientatedHeight.toDouble();
|
orientatedHeight = entity.orientatedHeight.toDouble();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (orientatedWidth == null) {
|
|
||||||
final entity = await ref.read(assetServiceProvider).loadExif(asset);
|
final entity = await ref.read(assetServiceProvider).loadExif(asset);
|
||||||
orientatedWidth = entity.orientatedWidth?.toDouble();
|
orientatedWidth = entity.orientatedWidth?.toDouble();
|
||||||
orientatedHeight = entity.orientatedHeight?.toDouble();
|
orientatedHeight = entity.orientatedHeight?.toDouble();
|
||||||
|
@ -196,6 +193,8 @@ class NativeVideoViewerPage extends HookConsumerWidget {
|
||||||
});
|
});
|
||||||
|
|
||||||
// When the position changes, seek to the position
|
// When the position changes, seek to the position
|
||||||
|
final seekThrottler =
|
||||||
|
useThrottler(interval: const Duration(milliseconds: 200));
|
||||||
ref.listen(videoPlayerControlsProvider.select((value) => value.position),
|
ref.listen(videoPlayerControlsProvider.select((value) => value.position),
|
||||||
(_, position) {
|
(_, position) {
|
||||||
final playerController = controller.value;
|
final playerController = controller.value;
|
||||||
|
@ -212,7 +211,7 @@ class NativeVideoViewerPage extends HookConsumerWidget {
|
||||||
final int seek = (asset.duration * (position / 100.0)).inSeconds;
|
final int seek = (asset.duration * (position / 100.0)).inSeconds;
|
||||||
if (seek != playbackInfo.position) {
|
if (seek != playbackInfo.position) {
|
||||||
try {
|
try {
|
||||||
playerController.seekTo(seek);
|
seekThrottler.run(() => playerController.seekTo(seek));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.severe('Error seeking to position $position: $error');
|
log.severe('Error seeking to position $position: $error');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue