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:
Narasimha-sc
2026-08-12 15:29:43 +01:00
committed by GitHub
parent 0a61b0ddea
commit abd5954675
7 changed files with 100 additions and 3 deletions
@@ -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)