mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(mobile): video player initialization (#17778)
* fix(mobile): video player initialization * nit
This commit is contained in:
parent
fda68f972f
commit
af36eaa61b
2 changed files with 12 additions and 12 deletions
|
|
@ -63,9 +63,12 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||
final loadAsset = renderList.loadAsset;
|
||||
final isPlayingMotionVideo = ref.watch(isPlayingMotionVideoProvider);
|
||||
|
||||
// This key is to prevent the video player from being re-initialized during
|
||||
// hero animation or device rotation.
|
||||
final videoPlayerKey = useMemoized(() => GlobalKey());
|
||||
final videoPlayerKeys = useRef<Map<int, GlobalKey>>({});
|
||||
|
||||
GlobalKey getVideoPlayerKey(int id) {
|
||||
videoPlayerKeys.value.putIfAbsent(id, () => GlobalKey());
|
||||
return videoPlayerKeys.value[id]!;
|
||||
}
|
||||
|
||||
Future<void> precacheNextImage(int index) async {
|
||||
if (!context.mounted) {
|
||||
|
|
@ -243,7 +246,7 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||
width: context.width,
|
||||
height: context.height,
|
||||
child: NativeVideoViewerPage(
|
||||
key: videoPlayerKey,
|
||||
key: getVideoPlayerKey(asset.id),
|
||||
asset: asset,
|
||||
image: Image(
|
||||
key: ValueKey(asset),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue