From ea19fa5f1abf973c9a12766d8ac8b88fcabe4aa4 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 27 Dec 2021 13:07:15 +0100 Subject: [PATCH] chore: Play stories videos full --- lib/pages/story/story_page.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/pages/story/story_page.dart b/lib/pages/story/story_page.dart index b793d3d4..abd06c53 100644 --- a/lib/pages/story/story_page.dart +++ b/lib/pages/story/story_page.dart @@ -48,6 +48,8 @@ class StoryPageController extends State { bool replyLoading = false; bool _modalOpened = false; + VideoPlayerController? _videoPlayerController; + void replyEmojiAction() async { if (replyLoading) return; _modalOpened = true; @@ -160,9 +162,15 @@ class StoryPageController extends State { } if (loadingMode) return; setState(() { - progress = progress += _step; + final video = _videoPlayerController; + if (video == null) { + progress += _step; + } else { + progress = video.value.position; + } }); - if (progress > maxProgress) { + final max = _videoPlayerController?.value.duration ?? maxProgress; + if (progress > max) { skip(); } }); @@ -181,8 +189,7 @@ class StoryPageController extends State { final matrixFile = await event.downloadAndDecryptAttachment(); final tmpDirectory = await getTemporaryDirectory(); final file = File(tmpDirectory.path + matrixFile.name); - final videoPlayerController = VideoPlayerController.file(file) - ..setLooping(true); + final videoPlayerController = VideoPlayerController.file(file); await videoPlayerController.initialize(); videoPlayerController.play(); return videoPlayerController;