mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-05 23:24:38 +00:00
ui: send dropped .webm as video only when it has a video track (#7354)
* ui: send dropped .webm as video only when it has a video track .webm is as commonly an audio-only container as a video one, so the extension alone cannot tell whether there is a frame to embed. Read the container to decide: files with a video track are sent as video, the rest as files. Only done for files attached without the user saying how to send them (drag & drop, paste). An explicitly picked video is still sent as one, so .webm is now listed in the video file picker too. * plan: send dropped .webm as video only when it has a video track
This commit is contained in:
+13
@@ -341,6 +341,19 @@ actual suspend fun getBitmapFromVideo(uri: URI, timestamp: Long?, random: Boolea
|
||||
VideoPlayerInterface.PreviewAndDuration(null, 0, 0)
|
||||
}
|
||||
|
||||
actual suspend fun hasVideoTrack(uri: URI): Boolean {
|
||||
val mmr = MediaMetadataRetriever()
|
||||
return try {
|
||||
mmr.setDataSource(androidAppContext, uri.toUri())
|
||||
mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO) == "yes"
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Utils.android hasVideoTrack error: ${e.message}")
|
||||
false
|
||||
} finally {
|
||||
mmr.release()
|
||||
}
|
||||
}
|
||||
|
||||
actual fun ByteArray.toBase64StringForPassphrase(): String = Base64.encodeToString(this, Base64.DEFAULT)
|
||||
|
||||
actual fun String.toByteArrayFromBase64ForPassphrase(): ByteArray = Base64.decode(this, Base64.DEFAULT)
|
||||
|
||||
Reference in New Issue
Block a user