motion photo (#1071)

This commit is contained in:
Neeraj Gupta 2023-05-06 15:00:52 +05:30 committed by GitHub
commit 02ce6387df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -49,7 +49,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
@override
void initState() {
_file = widget.file;
_showLivePhotoToast();
Future.microtask(() => _showHintForMotionPhotoPlay).ignore();
super.initState();
}
@ -125,7 +125,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
return;
}
_isLoadingVideoPlayer = true;
io.File? videoFile = _file.fileType == FileType.livePhoto
final io.File? videoFile = _file.fileType == FileType.livePhoto
? await _getLivePhotoVideo()
: await _getMotionPhotoVideo();
@ -178,7 +178,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
});
if (imageFile != null) {
final motionPhoto = MotionPhotos(imageFile.path);
final index = motionPhoto.getMotionVideoIndex();
final index = await motionPhoto.getMotionVideoIndex();
if (index != null) {
if (widget.file.pubMagicMetadata?.mvi == null &&
(widget.file.ownerID ?? 0) == Configuration.instance.getUserID()!) {
@ -208,11 +208,15 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
});
}
void _showLivePhotoToast() async {
void _showHintForMotionPhotoPlay() async {
if (widget.file.fileType != FileType.livePhoto ||
widget.file.pubMagicMetadata?.mvi != null) {
return;
}
final preferences = await SharedPreferences.getInstance();
final int promptTillNow = preferences.getInt(livePhotoToastCounterKey) ?? 0;
if (promptTillNow < maxLivePhotoToastCount && mounted) {
showToast(context, S.of(context).pressAndHoldToPlayVideo);
showShortToast(context, S.of(context).pressAndHoldToPlayVideo);
preferences.setInt(livePhotoToastCounterKey, promptTillNow + 1);
}
}

View file

@ -163,7 +163,7 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(ente.File file) async {
if (io.Platform.isAndroid && asset.type == AssetType.image) {
try {
motionPhotoStartingIndex =
MotionPhotos(sourceFile.path).getMotionVideoIndex()?.start;
(await MotionPhotos(sourceFile.path).getMotionVideoIndex())?.start;
} catch (e) {
_logger.severe('error while detecthing motion photo start index', e);
}

View file

@ -1186,7 +1186,7 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: ceeaff6e16bd9e3c98e7da2b1109dc04a93098b9
resolved-ref: "989ea86e513755d9a8cf945e7522100fc2877639"
url: "https://github.com/ente-io/motion_photo.git"
source: git
version: "0.0.1"