Fixing motion photo playing
This commit is contained in:
@@ -67,12 +67,11 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
final settings = ref.watch(appSettingsServiceProvider);
|
final settings = ref.watch(appSettingsServiceProvider);
|
||||||
final isLoadPreview = useState(AppSettingsEnum.loadPreview.defaultValue);
|
final isLoadPreview = useState(AppSettingsEnum.loadPreview.defaultValue);
|
||||||
final isLoadOriginal = useState(AppSettingsEnum.loadOriginal.defaultValue);
|
final isLoadOriginal = useState(AppSettingsEnum.loadOriginal.defaultValue);
|
||||||
final isZoomed = useState<bool>(false);
|
final isZoomed = useState(false);
|
||||||
final isPlayingMotionVideo = useState(false);
|
final isPlayingMotionVideo = useState(false);
|
||||||
Offset? localPosition;
|
Offset? localPosition;
|
||||||
final currentIndex = useState(initialIndex);
|
final currentIndex = useState(initialIndex);
|
||||||
final currentAsset = loadAsset(currentIndex.value);
|
final currentAsset = loadAsset(currentIndex.value);
|
||||||
|
|
||||||
// Update is playing motion video
|
// Update is playing motion video
|
||||||
ref.listen(videoPlaybackValueProvider.select((v) => v.state), (_, state) {
|
ref.listen(videoPlaybackValueProvider.select((v) => v.state), (_, state) {
|
||||||
isPlayingMotionVideo.value = state == VideoPlaybackState.playing;
|
isPlayingMotionVideo.value = state == VideoPlaybackState.playing;
|
||||||
@@ -90,6 +89,8 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
Asset asset = stackIndex.value == -1
|
Asset asset = stackIndex.value == -1
|
||||||
? currentAsset
|
? currentAsset
|
||||||
: stackElements.elementAt(stackIndex.value);
|
: stackElements.elementAt(stackIndex.value);
|
||||||
|
|
||||||
|
final isMotionPhoto = asset.livePhotoVideoId != null;
|
||||||
final isOwner = asset.ownerId == ref.watch(currentUserProvider)?.isarId;
|
final isOwner = asset.ownerId == ref.watch(currentUserProvider)?.isarId;
|
||||||
final isPartner = ref
|
final isPartner = ref
|
||||||
.watch(partnerSharedWithProvider)
|
.watch(partnerSharedWithProvider)
|
||||||
@@ -115,7 +116,6 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
settings.getSetting<bool>(AppSettingsEnum.loadPreview);
|
settings.getSetting<bool>(AppSettingsEnum.loadPreview);
|
||||||
isLoadOriginal.value =
|
isLoadOriginal.value =
|
||||||
settings.getSetting<bool>(AppSettingsEnum.loadOriginal);
|
settings.getSetting<bool>(AppSettingsEnum.loadOriginal);
|
||||||
isPlayingMotionVideo.value = false;
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
@@ -482,8 +482,7 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
showStack: showStack,
|
showStack: showStack,
|
||||||
stackIndex: stackIndex.value,
|
stackIndex: stackIndex.value,
|
||||||
asset: asset,
|
asset: asset,
|
||||||
showVideoPlayerControls:
|
showVideoPlayerControls: !asset.isImage && !isMotionPhoto,
|
||||||
!asset.isImage && !isPlayingMotionVideo.value,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -112,9 +112,11 @@ class VideoViewerPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
// Hide the controls
|
// Hide the controls
|
||||||
// Done in a microtask to avoid setting the state while the widget is building
|
// Done in a microtask to avoid setting the state while the widget is building
|
||||||
Future.microtask(
|
if (!isMotionVideo) {
|
||||||
() => ref.read(showControlsProvider.notifier).show = false,
|
Future.microtask(
|
||||||
);
|
() => ref.read(showControlsProvider.notifier).show = false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final video = controller.videoPlayerController.value;
|
final video = controller.videoPlayerController.value;
|
||||||
|
|
||||||
@@ -131,7 +133,8 @@ class VideoViewerPage extends HookConsumerWidget {
|
|||||||
[controller],
|
[controller],
|
||||||
);
|
);
|
||||||
|
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.sizeOf(context);
|
||||||
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
onPopInvoked: (pop) {
|
onPopInvoked: (pop) {
|
||||||
ref.read(videoPlaybackValueProvider.notifier).value =
|
ref.read(videoPlaybackValueProvider.notifier).value =
|
||||||
|
|||||||
Reference in New Issue
Block a user