chore: Fix video stories

onboarding
Christian Pauly 4 years ago
parent 6ef0c8c6da
commit 100a264888

@ -196,16 +196,18 @@ class StoryPageController extends State<StoryPage> {
String get roomId => VRouter.of(context).pathParameters['roomid'] ?? '';
Future<VideoPlayerController>? loadVideoControllerFuture;
Future<VideoPlayerController?>? loadVideoControllerFuture;
Future<VideoPlayerController> loadVideoController(Event event) async {
Future<VideoPlayerController?> loadVideoController(Event event) async {
try {
final matrixFile = await event.downloadAndDecryptAttachment();
if (!mounted) return null;
final tmpDirectory = await getTemporaryDirectory();
final fileName =
event.content.tryGet<String>('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();

@ -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<VideoPlayerController>(
FutureBuilder<VideoPlayerController?>(
future: controller.loadVideoControllerFuture ??=
controller.loadVideoController(event),
builder: (context, snapshot) {

Loading…
Cancel
Save