|
|
@ -10,7 +10,7 @@ import android.os.Message; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
import android.widget.ProgressBar; |
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
|
|
|
|
import com.frank.ffmpeg.R; |
|
|
|
import com.frank.ffmpeg.R; |
|
|
|
import com.frank.ffmpeg.handler.FFmpegHandler; |
|
|
|
import com.frank.ffmpeg.handler.FFmpegHandler; |
|
|
@ -18,10 +18,12 @@ import com.frank.ffmpeg.util.FFmpegUtil; |
|
|
|
import com.frank.ffmpeg.util.FileUtil; |
|
|
|
import com.frank.ffmpeg.util.FileUtil; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_BEGIN; |
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_BEGIN; |
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_CONTINUE; |
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_CONTINUE; |
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_FINISH; |
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_FINISH; |
|
|
|
|
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_PROGRESS; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* using ffmpeg to handle media |
|
|
|
* using ffmpeg to handle media |
|
|
@ -34,7 +36,8 @@ public class MediaHandleActivity extends BaseActivity { |
|
|
|
private String videoFile; |
|
|
|
private String videoFile; |
|
|
|
private String temp = PATH + File.separator + "temp.mp4"; |
|
|
|
private String temp = PATH + File.separator + "temp.mp4"; |
|
|
|
|
|
|
|
|
|
|
|
private ProgressBar progressMedia; |
|
|
|
private LinearLayout layoutProgress; |
|
|
|
|
|
|
|
private TextView txtProgress; |
|
|
|
private int viewId; |
|
|
|
private int viewId; |
|
|
|
private LinearLayout layoutMediaHandle; |
|
|
|
private LinearLayout layoutMediaHandle; |
|
|
|
private FFmpegHandler ffmpegHandler; |
|
|
|
private FFmpegHandler ffmpegHandler; |
|
|
@ -46,7 +49,7 @@ public class MediaHandleActivity extends BaseActivity { |
|
|
|
super.handleMessage(msg); |
|
|
|
super.handleMessage(msg); |
|
|
|
switch (msg.what) { |
|
|
|
switch (msg.what) { |
|
|
|
case MSG_CONTINUE: |
|
|
|
case MSG_CONTINUE: |
|
|
|
String audioFile = PATH + File.separator + "tiger.mp3";//tiger.mp3
|
|
|
|
String audioFile = PATH + File.separator + "tiger.mp3"; |
|
|
|
String muxFile = PATH + File.separator + "media-mux.mp4"; |
|
|
|
String muxFile = PATH + File.separator + "media-mux.mp4"; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -75,13 +78,22 @@ public class MediaHandleActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case MSG_BEGIN: |
|
|
|
case MSG_BEGIN: |
|
|
|
progressMedia.setVisibility(View.VISIBLE); |
|
|
|
layoutProgress.setVisibility(View.VISIBLE); |
|
|
|
layoutMediaHandle.setVisibility(View.GONE); |
|
|
|
layoutMediaHandle.setVisibility(View.GONE); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case MSG_FINISH: |
|
|
|
case MSG_FINISH: |
|
|
|
progressMedia.setVisibility(View.GONE); |
|
|
|
layoutProgress.setVisibility(View.GONE); |
|
|
|
layoutMediaHandle.setVisibility(View.VISIBLE); |
|
|
|
layoutMediaHandle.setVisibility(View.VISIBLE); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case MSG_PROGRESS: |
|
|
|
|
|
|
|
int progress = msg.arg1; |
|
|
|
|
|
|
|
if (progress > 0) { |
|
|
|
|
|
|
|
txtProgress.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
txtProgress.setText(String.format(Locale.getDefault(), "%d%%", progress)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
txtProgress.setVisibility(View.INVISIBLE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -103,7 +115,8 @@ public class MediaHandleActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initView() { |
|
|
|
private void initView() { |
|
|
|
progressMedia = getView(R.id.progress_media); |
|
|
|
layoutProgress = getView(R.id.layout_progress); |
|
|
|
|
|
|
|
txtProgress = getView(R.id.txt_progress); |
|
|
|
layoutMediaHandle = getView(R.id.layout_media_handle); |
|
|
|
layoutMediaHandle = getView(R.id.layout_media_handle); |
|
|
|
initViewsWithClick( |
|
|
|
initViewsWithClick( |
|
|
|
R.id.btn_mux, |
|
|
|
R.id.btn_mux, |
|
|
|