From 9ddf10009a598c4f2cc67d7ab1357ec722c48746 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 28 Dec 2021 23:08:27 +0100 Subject: [PATCH] chore: Fix video stories --- lib/pages/story/story_page.dart | 6 ++++-- lib/pages/story/story_view.dart | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pages/story/story_page.dart b/lib/pages/story/story_page.dart index 8ec38ce1..11c17a30 100644 --- a/lib/pages/story/story_page.dart +++ b/lib/pages/story/story_page.dart @@ -196,16 +196,18 @@ class StoryPageController extends State { String get roomId => VRouter.of(context).pathParameters['roomid'] ?? ''; - Future? loadVideoControllerFuture; + Future? loadVideoControllerFuture; - Future loadVideoController(Event event) async { + Future loadVideoController(Event event) async { try { final matrixFile = await event.downloadAndDecryptAttachment(); + if (!mounted) return null; final tmpDirectory = await getTemporaryDirectory(); final fileName = event.content.tryGet('filename') ?? 'unknown_story_video.mp4'; final file = File(tmpDirectory.path + '/' + fileName); await file.writeAsBytes(matrixFile.bytes); + if (!mounted) return null; final videoPlayerController = _videoPlayerController = VideoPlayerController.file(file); await videoPlayerController.initialize(); diff --git a/lib/pages/story/story_view.dart b/lib/pages/story/story_view.dart index 482dee52..eceb1287 100644 --- a/lib/pages/story/story_view.dart +++ b/lib/pages/story/story_view.dart @@ -72,7 +72,7 @@ class StoryView extends StatelessWidget { ), ), actions: [ - if (!controller.isOwnStory) + if (!controller.isOwnStory && currentEvent != null) AnimatedOpacity( duration: const Duration(seconds: 1), opacity: controller.isHold ? 0 : 1, @@ -159,7 +159,7 @@ class StoryView extends StatelessWidget { children: [ if (event.messageType == MessageTypes.Video && PlatformInfos.isMobile) - FutureBuilder( + FutureBuilder( future: controller.loadVideoControllerFuture ??= controller.loadVideoController(event), builder: (context, snapshot) {