From becc4e87739e0ffd0819fd286c536b96d8c856e3 Mon Sep 17 00:00:00 2001 From: Qiming Date: Sun, 6 Nov 2022 10:38:04 +0800 Subject: [PATCH] =?UTF-8?q?Probe=E4=B8=8D=E6=8A=93=E5=B8=A7=E6=97=B6UI?= =?UTF-8?q?=E4=B8=8A=E6=B8=85=E9=99=A4=E4=B9=8B=E5=89=8D=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E7=89=87=EF=BC=9B=E7=A1=AE=E4=BF=9D=E6=8A=93?= =?UTF-8?q?=E5=B8=A7=E6=97=B6=E9=97=B4=E7=82=B9=E4=B8=8D=E8=B6=85=E8=BF=87?= =?UTF-8?q?duration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frank/ffmpeg/activity/ProbeFormatActivity.kt | 13 +++++++++---- .../frank/ffmpeg/metadata/FFmpegMediaRetriever.java | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.kt index 0119b78..ca3dfe7 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.kt @@ -57,9 +57,8 @@ class ProbeFormatActivity : BaseActivity() { MSG_FINISH -> { progressProbe!!.visibility = View.GONE layoutProbe!!.visibility = View.VISIBLE - val result = msg.obj?: msg.obj - if (result != null) { - val mediaInfo = JsonParseTool.stringFormat(result as MediaBean) + if (msg.obj != null) { + val mediaInfo = JsonParseTool.stringFormat(msg.obj as MediaBean) if (!mediaInfo.isNullOrEmpty() && txtProbeFormat != null) { txtProbeFormat!!.text = mediaInfo } @@ -108,6 +107,7 @@ class ProbeFormatActivity : BaseActivity() { when (view?.id) { R.id.btn_probe_format -> { + findViewById(R.id.img_frame).setImageBitmap(null) doHandleProbe(filePath) } R.id.btn_retrieve_format -> { @@ -188,7 +188,12 @@ class ProbeFormatActivity : BaseActivity() { mHandler.obtainMessage(MSG_INFO, resultBuilder.toString()).sendToTarget() // Retrieve frame with timeUs - val bitmap = retriever.getFrameAtTime(5 * 1000000) + val frameTime = if (duration != null) { + duration.toLong() / 3 * 1000 + } else { + 5 * 1000000 + } + val bitmap = retriever.getFrameAtTime(frameTime) // Retrieve audio thumbnail, if it has embedded // val bitmap = retriever.audioThumbnail if (bitmap != null) { diff --git a/app/src/main/java/com/frank/ffmpeg/metadata/FFmpegMediaRetriever.java b/app/src/main/java/com/frank/ffmpeg/metadata/FFmpegMediaRetriever.java index f24796d..405d466 100755 --- a/app/src/main/java/com/frank/ffmpeg/metadata/FFmpegMediaRetriever.java +++ b/app/src/main/java/com/frank/ffmpeg/metadata/FFmpegMediaRetriever.java @@ -31,7 +31,7 @@ public class FFmpegMediaRetriever { public FFmpegMediaRetriever() { native_init(); - native_setup(); + native_setup(); } public void setDataSource(String path) {