chore: Play stories videos full

This commit is contained in:
Christian Pauly 2021-12-27 13:07:15 +01:00
parent d49515011d
commit ea19fa5f1a

View File

@ -48,6 +48,8 @@ class StoryPageController extends State<StoryPage> {
bool replyLoading = false; bool replyLoading = false;
bool _modalOpened = false; bool _modalOpened = false;
VideoPlayerController? _videoPlayerController;
void replyEmojiAction() async { void replyEmojiAction() async {
if (replyLoading) return; if (replyLoading) return;
_modalOpened = true; _modalOpened = true;
@ -160,9 +162,15 @@ class StoryPageController extends State<StoryPage> {
} }
if (loadingMode) return; if (loadingMode) return;
setState(() { 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(); skip();
} }
}); });
@ -181,8 +189,7 @@ class StoryPageController extends State<StoryPage> {
final matrixFile = await event.downloadAndDecryptAttachment(); final matrixFile = await event.downloadAndDecryptAttachment();
final tmpDirectory = await getTemporaryDirectory(); final tmpDirectory = await getTemporaryDirectory();
final file = File(tmpDirectory.path + matrixFile.name); final file = File(tmpDirectory.path + matrixFile.name);
final videoPlayerController = VideoPlayerController.file(file) final videoPlayerController = VideoPlayerController.file(file);
..setLooping(true);
await videoPlayerController.initialize(); await videoPlayerController.initialize();
videoPlayerController.play(); videoPlayerController.play();
return videoPlayerController; return videoPlayerController;