fix: Videoplayer filenames

This commit is contained in:
Christian Pauly 2022-01-27 21:01:29 +01:00
parent f17ae118d0
commit 89f32bd4c3
2 changed files with 4 additions and 4 deletions

View File

@ -66,8 +66,7 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
await widget.event.downloadAndDecryptAttachmentCached(); await widget.event.downloadAndDecryptAttachmentCached();
if (matrixFile == null) throw ('Download failed'); if (matrixFile == null) throw ('Download failed');
final tempDir = await getTemporaryDirectory(); final tempDir = await getTemporaryDirectory();
final fileName = final fileName = widget.event.infoMap['url'] as String;
widget.event.content.tryGet<String>('filename') ?? matrixFile.name;
final file = File('${tempDir.path}/$fileName'); final file = File('${tempDir.path}/$fileName');
await file.writeAsBytes(matrixFile.bytes); await file.writeAsBytes(matrixFile.bytes);

View File

@ -40,8 +40,9 @@ class _EventVideoPlayerState extends State<EventVideoPlayer> {
final blob = html.Blob([videoFile.bytes]); final blob = html.Blob([videoFile.bytes]);
_networkUri = html.Url.createObjectUrlFromBlob(blob); _networkUri = html.Url.createObjectUrlFromBlob(blob);
} else { } else {
final tmpDir = await getTemporaryDirectory(); final tempDir = await getTemporaryDirectory();
final file = File(tmpDir.path + videoFile.name); final fileName = widget.event.infoMap['url'] as String;
final file = File('${tempDir.path}/$fileName');
if (await file.exists() == false) { if (await file.exists() == false) {
await file.writeAsBytes(videoFile.bytes); await file.writeAsBytes(videoFile.bytes);
} }