From 288635473b64705fb5a4d5523e0a0d9ca81bee23 Mon Sep 17 00:00:00 2001 From: sherlock Date: Fri, 23 Feb 2024 14:36:56 +0700 Subject: [PATCH] TW-1269: can't play video in safari --- lib/presentation/extensions/send_file_web_extension.dart | 4 ++-- lib/presentation/mixins/handle_video_download_mixin.dart | 2 +- lib/utils/extension/web_url_creation_extension.dart | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/presentation/extensions/send_file_web_extension.dart b/lib/presentation/extensions/send_file_web_extension.dart index f8f3f0e083..014aba0b7d 100644 --- a/lib/presentation/extensions/send_file_web_extension.dart +++ b/lib/presentation/extensions/send_file_web_extension.dart @@ -292,7 +292,7 @@ extension SendFileWebExtension on Room { ) async { if (originalFile.bytes == null) return null; try { - final url = originalFile.bytes?.toWebUrl(); + final url = originalFile.bytes?.toWebUrl(mimeType: originalFile.mimeType); if (url == null) { throw Exception('Missing bytes in $originalFile'); } @@ -328,7 +328,7 @@ extension SendFileWebExtension on Room { return null; } try { - final url = originalFile.bytes?.toWebUrl(); + final url = originalFile.bytes?.toWebUrl(mimeType: originalFile.mimeType); if (url == null) { throw Exception('$originalFile is empty'); } diff --git a/lib/presentation/mixins/handle_video_download_mixin.dart b/lib/presentation/mixins/handle_video_download_mixin.dart index 44c6d3ecbc..b131de7ec9 100644 --- a/lib/presentation/mixins/handle_video_download_mixin.dart +++ b/lib/presentation/mixins/handle_video_download_mixin.dart @@ -22,7 +22,7 @@ mixin HandleVideoDownloadMixin { lastSelectedVideoEventId = event.eventId; if (PlatformInfos.isWeb) { final videoBytes = await event.downloadAndDecryptAttachment(); - final url = videoBytes.bytes?.toWebUrl(); + final url = videoBytes.bytes?.toWebUrl(mimeType: videoBytes.mimeType); if (url == null) { throw Exception('$videoBytes is null'); } diff --git a/lib/utils/extension/web_url_creation_extension.dart b/lib/utils/extension/web_url_creation_extension.dart index 782914a5c3..f226f276d7 100644 --- a/lib/utils/extension/web_url_creation_extension.dart +++ b/lib/utils/extension/web_url_creation_extension.dart @@ -3,8 +3,8 @@ import 'dart:typed_data'; import 'package:universal_html/html.dart' as html; extension WebUrlCreationExtension on Uint8List { - String toWebUrl() { - final blob = html.Blob([this]); + String toWebUrl({required String mimeType}) { + final blob = html.Blob([this], mimeType); return html.Url.createObjectUrlFromBlob(blob); } }