add progress callback

add progress callback
pull/166/head
xufulong 5 years ago
parent a93bd3d420
commit d96ec26c64
  1. 2
      app/src/main/java/com/frank/ffmpeg/FFmpegCmd.java
  2. 5
      app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java

@ -70,6 +70,7 @@ public class FFmpegCmd {
* @param onHandleListener the callback for executing command * @param onHandleListener the callback for executing command
*/ */
public static void execute(final List<String[]> commands, final OnHandleListener onHandleListener) { public static void execute(final List<String[]> commands, final OnHandleListener onHandleListener) {
mProgressListener = onHandleListener;
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -87,6 +88,7 @@ public class FFmpegCmd {
if (onHandleListener != null) { if (onHandleListener != null) {
onHandleListener.onEnd(result, null); onHandleListener.onEnd(result, null);
} }
mProgressListener = null;
} }
}).start(); }).start();
} }

@ -89,6 +89,11 @@ public class FFmpegHandler {
mHandler.obtainMessage(MSG_BEGIN).sendToTarget(); mHandler.obtainMessage(MSG_BEGIN).sendToTarget();
} }
@Override
public void onProgress(int progress, int duration) {
mHandler.obtainMessage(MSG_PROGRESS, progress, duration).sendToTarget();
}
@Override @Override
public void onEnd(int resultCode, String resultMsg) { public void onEnd(int resultCode, String resultMsg) {
Log.i(TAG, "handle onEnd..."); Log.i(TAG, "handle onEnd...");

Loading…
Cancel
Save