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 _modalOpened = false;
VideoPlayerController? _videoPlayerController;
void replyEmojiAction() async {
if (replyLoading) return;
_modalOpened = true;
@ -160,9 +162,15 @@ class StoryPageController extends State<StoryPage> {
}
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<StoryPage> {
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;