Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class _AssetPageState extends ConsumerState<AssetPage> {
}

return PhotoView.customChild(
key: ValueKey(displayAsset),
key: ValueKey((displayAsset.heroTag, '_video_gesture_layer')),
onDragStart: _onDragStart,
onDragUpdate: _onDragUpdate,
onDragEnd: _onDragEnd,
Expand All @@ -359,7 +359,7 @@ class _AssetPageState extends ConsumerState<AssetPage> {
enablePanAlways: true,
backgroundDecoration: backgroundDecoration,
child: NativeVideoViewer(
key: ValueKey(displayAsset),
key: ValueKey((displayAsset.heroTag, '_video_platform_view')),
asset: displayAsset,
scaleStateNotifier: _videoScaleStateNotifier,
disableScaleGestures: showingDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,21 @@ class NativeVideoViewer extends HookConsumerWidget {
}

ref.listen(currentAssetNotifier, (_, value) {
final isCurrent = _isCurrentAsset(asset, value);
// This is the same asset with different metadata (e.g. isFavorite changed), update the ref
if (value != null && value != asset && isCurrent) {
currentAsset.value = value;
isVisible.value = isCurrent;
return;
}

final playerController = controller.value;
if (playerController != null && value != asset) {
removeListeners(playerController);
}

if (value != null) {
isVisible.value = _isCurrentAsset(value, asset);
isVisible.value = isCurrent;
}
final curAsset = currentAsset.value;
if (curAsset == asset) {
Expand Down Expand Up @@ -423,17 +431,20 @@ class NativeVideoViewer extends HookConsumerWidget {
if (!isVisible.value || controller.value == null) Center(key: ValueKey(asset.heroTag), child: image),
if (aspectRatio.value != null && !isCasting && isCurrent)
Visibility.maintain(
key: ValueKey(asset),
key: ValueKey((asset.heroTag, '_video_layer')),
visible: isVisible.value,
child: PhotoView.customChild(
key: ValueKey(asset),
key: ValueKey((asset.heroTag, '_video_gesture_layer')),
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: NativeVideoPlayerView(
key: ValueKey((asset.heroTag, '_video_platform_view')),
onViewReady: initController,
),
),
),
if (showControls) const Center(child: VideoViewerControls()),
Expand Down
Loading