π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix: source preview file as videoplayer's input
Prateek Sunalbbfa447e42fc
diff --git a/mobile/lib/ui/viewer/file/preview_video_widget.dart b/mobile/lib/ui/viewer/file/preview_video_widget.dartindex 2e687a27e1..d8ce9cb790 100644--- a/mobile/lib/ui/viewer/file/preview_video_widget.dart+++ b/mobile/lib/ui/viewer/file/preview_video_widget.dart@@ -28,14 +28,16 @@ class PreviewVideoWidget extends StatefulWidget {final bool? autoPlay;final String? tagPrefix;final Function(bool)? playbackCallback;+ final File preview;const PreviewVideoWidget(this.file, {+ required this.preview,this.autoPlay = false,this.tagPrefix,this.playbackCallback,- Key? key,- }) : super(key: key);+ super.key,+ });@overrideState<PreviewVideoWidget> createState() => _PreviewVideoWidgetState();@@ -54,31 +56,8 @@ class _PreviewVideoWidgetState extends State<PreviewVideoWidget> {@overridevoid initState() {super.initState();- if (widget.file.isRemoteFile) {- _loadNetworkVideo();- _setFileSizeIfNull();- } else if (widget.file.isSharedMediaToAppSandbox) {- final localFile = File(getSharedMediaFilePath(widget.file));- if (localFile.existsSync()) {- _logger.fine("loading from app cache");- _setVideoPlayerController(file: localFile);- } else if (widget.file.uploadedFileID != null) {- _loadNetworkVideo();- }- } else {- widget.file.getAsset.then((asset) async {- if (asset == null || !(await asset.exists)) {- if (widget.file.uploadedFileID != null) {- _loadNetworkVideo();- }- } else {- // ignore: unawaited_futures- asset.getMediaUrl().then((url) {- _setVideoPlayerController(url: url);- });- }- });- }++ _setVideoPlayerController();_fileSwipeLockEventSubscription =Bus.instance.on<GuestViewEvent>().listen((event) {setState(() {@@ -141,7 +120,6 @@ class _PreviewVideoWidgetState extends State<PreviewVideoWidget> {}void _setVideoPlayerController({- String? url,File? file,}) {if (!mounted) {@@ -151,11 +129,7 @@ class _PreviewVideoWidgetState extends State<PreviewVideoWidget> {return;}VideoPlayerController videoPlayerController;- if (url != null) {- videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(url));- } else {- videoPlayerController = VideoPlayerController.file(file!);- }+ videoPlayerController = VideoPlayerController.file(file ?? widget.preview);debugPrint("videoPlayerController: $videoPlayerController");_videoPlayerController = videoPlayerControllerdiff --git a/mobile/lib/ui/viewer/file/video_view_widget.dart b/mobile/lib/ui/viewer/file/video_view_widget.dartindex 7d1050531e..a9dbd0b385 100644--- a/mobile/lib/ui/viewer/file/video_view_widget.dart+++ b/mobile/lib/ui/viewer/file/video_view_widget.dart@@ -13,6 +13,7 @@ import "package:photos/core/event_bus.dart";import "package:photos/generated/l10n.dart";import 'package:photos/models/file/file.dart';import "package:photos/service_locator.dart";+import "package:photos/services/preview_video_store.dart";import "package:photos/ui/actions/file/file_actions.dart";import "package:photos/ui/viewer/file/preview_video_widget.dart";import 'package:photos/ui/viewer/file/thumbnail_widget.dart';@@ -56,9 +57,7 @@ class _VideoViewWidgetState extends State<VideoViewWidget> {void _checkForPreview() {if (!flagService.internalUser) return;- getPreviewFileFromServer(- widget.file,- ).then((file) {+ PreviewVideoStore.instance.getPlaylist(widget.file).then((file) {if (!mounted) return;if (file != null) {isCheckingForPreview = false;@@ -96,6 +95,7 @@ class _VideoViewWidgetState extends State<VideoViewWidget> {if (previewFile != null) {return PreviewVideoWidget(widget.file,+ preview: previewFile!,tagPrefix: widget.tagPrefix,playbackCallback: widget.playbackCallback,);diff --git a/mobile/lib/utils/file_util.dart b/mobile/lib/utils/file_util.dartindex 85eb60ddab..8b0f76669f 100644--- a/mobile/lib/utils/file_util.dart+++ b/mobile/lib/utils/file_util.dart@@ -130,45 +130,6 @@ void removeCallBack(EnteFile file) {}}-Future<File?> getPreviewFileFromServer(- EnteFile file, {- ProgressCallback? progressCallback,-}) async {- final cacheManager = DefaultCacheManager();- final fileFromCache = await cacheManager.getFileFromCache(file.downloadUrl);- if (fileFromCache != null) {- return fileFromCache.file;- }- final downloadID = file.uploadedFileID.toString();-- if (progressCallback != null) {- _progressCallbacks[downloadID] = progressCallback;- }-- if (!_fileDownloadsInProgress.containsKey(downloadID)) {- final completer = Completer<File?>();- _fileDownloadsInProgress[downloadID] = completer.future;-- Future<File?> downloadFuture;-- downloadFuture = _downloadAndCache(- file,- cacheManager,- progressCallback: (count, total) {- _progressCallbacks[downloadID]?.call(count, total);- },- );-- // ignore: unawaited_futures- downloadFuture.then((downloadedFile) async {- completer.complete(downloadedFile);- await _fileDownloadsInProgress.remove(downloadID);- _progressCallbacks.remove(downloadID);- });- }- return _fileDownloadsInProgress[downloadID];-}-Future<File?> getFileFromServer(EnteFile file, {ProgressCallback? progressCallback,