From 45ef85b772af12e59bfa90f174776369f6acde0a Mon Sep 17 00:00:00 2001 From: xufulong <839789740@qq.com> Date: Fri, 10 Jan 2020 00:17:33 +0800 Subject: [PATCH] show media format data show media format data --- .../frank/ffmpeg/activity/ProbeFormatActivity.java | 9 ++++++--- .../java/com/frank/ffmpeg/handler/FFmpegHandler.java | 12 +++++++----- app/src/main/res/layout/activity_probe.xml | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.java b/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.java index 1e4bc93..d2de71d 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.java +++ b/app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.java @@ -13,6 +13,8 @@ import android.widget.TextView; import com.frank.ffmpeg.R; import com.frank.ffmpeg.handler.FFmpegHandler; +import com.frank.ffmpeg.model.MediaBean; +import com.frank.ffmpeg.tool.JsonParseTool; import com.frank.ffmpeg.util.FFmpegUtil; import com.frank.ffmpeg.util.FileUtil; @@ -44,9 +46,10 @@ public class ProbeFormatActivity extends BaseActivity { case MSG_FINISH: progressProbe.setVisibility(View.GONE); layoutProbe.setVisibility(View.VISIBLE); - String result = (String) msg.obj; - if (!TextUtils.isEmpty(result) && txtProbeFormat != null) { - txtProbeFormat.setText(result); + MediaBean result = (MediaBean) msg.obj; + String resultFormat = JsonParseTool.stringFormat(result); + if (!TextUtils.isEmpty(resultFormat) && txtProbeFormat != null) { + txtProbeFormat.setText(resultFormat); } break; default: diff --git a/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java b/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java index ab7f383..a4086da 100644 --- a/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java +++ b/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java @@ -5,6 +5,8 @@ import android.util.Log; import com.frank.ffmpeg.FFmpegCmd; import com.frank.ffmpeg.listener.OnHandleListener; +import com.frank.ffmpeg.model.MediaBean; +import com.frank.ffmpeg.tool.JsonParseTool; /** * Handler消息处理器 @@ -78,12 +80,12 @@ public class FFmpegHandler { @Override public void onEnd(int resultCode, String resultMsg) { - Log.e(TAG, "handle ffprobe onEnd result=" + resultMsg); - if(isContinue) { - mHandler.obtainMessage(MSG_CONTINUE).sendToTarget(); - }else { - mHandler.obtainMessage(MSG_FINISH, resultMsg).sendToTarget(); + Log.i(TAG, "handle ffprobe onEnd result=" + resultMsg); + MediaBean mediaBean = null; + if(resultMsg != null && !resultMsg.isEmpty()) { + mediaBean = JsonParseTool.parseMediaFormat(resultMsg); } + mHandler.obtainMessage(MSG_FINISH, mediaBean).sendToTarget(); } }); } diff --git a/app/src/main/res/layout/activity_probe.xml b/app/src/main/res/layout/activity_probe.xml index 158e794..d90fc38 100644 --- a/app/src/main/res/layout/activity_probe.xml +++ b/app/src/main/res/layout/activity_probe.xml @@ -21,6 +21,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dp" + android:textColor="@color/colorPrimary" + android:textSize="16sp" android:layout_below="@+id/btn_probe_format" android:layout_centerHorizontal="true"/>