parent
a7c47023e2
commit
4f08770cf0
@ -1,118 +0,0 @@ |
||||
package com.frank.ffmpeg.activity; |
||||
|
||||
import android.annotation.SuppressLint; |
||||
import android.os.Environment; |
||||
import android.os.Handler; |
||||
import android.os.Message; |
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
import android.widget.LinearLayout; |
||||
import android.widget.VideoView; |
||||
import com.frank.ffmpeg.R; |
||||
import com.frank.ffmpeg.handler.FFmpegHandler; |
||||
import com.frank.ffmpeg.util.FFmpegUtil; |
||||
import com.frank.ffmpeg.util.FileUtil; |
||||
import java.io.File; |
||||
|
||||
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_FINISH; |
||||
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_TOAST; |
||||
|
||||
/** |
||||
* 先处理视频反序,再视频倒播 |
||||
* Created by frank on 2018/9/12. |
||||
*/ |
||||
|
||||
public class VideoReverseActivity extends BaseActivity { |
||||
|
||||
private final static String ROOT_PATH = Environment.getExternalStorageDirectory().getPath(); |
||||
private String VIDEO_NORMAL_PATH = ""; |
||||
private final static String VIDEO_REVERSE_PATH = ROOT_PATH + File.separator + "reverse.mp4"; |
||||
|
||||
private LinearLayout loading; |
||||
private VideoView videoReverse; |
||||
private FFmpegHandler ffmpegHandler; |
||||
|
||||
@SuppressLint("HandlerLeak") |
||||
private Handler mHandler = new Handler(){ |
||||
@Override |
||||
public void handleMessage(Message msg) { |
||||
super.handleMessage(msg); |
||||
if (msg.what == MSG_FINISH){ |
||||
changeVisibility(); |
||||
startPlay(); |
||||
} else if (msg.what == MSG_TOAST) { |
||||
showToast(getString(R.string.please_click_select)); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
int getLayoutId() { |
||||
return R.layout.activity_video_reverse; |
||||
} |
||||
|
||||
@Override |
||||
protected void onCreate(Bundle savedInstanceState) { |
||||
super.onCreate(savedInstanceState); |
||||
|
||||
initView(); |
||||
initPlayer(); |
||||
mHandler.sendEmptyMessageDelayed(MSG_TOAST, 500); |
||||
ffmpegHandler = new FFmpegHandler(mHandler); |
||||
} |
||||
|
||||
private void initView() { |
||||
loading = getView(R.id.layout_loading); |
||||
videoReverse = getView(R.id.video_reverse); |
||||
loading.setVisibility(View.GONE); |
||||
} |
||||
|
||||
private void changeVisibility(){ |
||||
loading.setVisibility(View.GONE); |
||||
videoReverse.setVisibility(View.VISIBLE); |
||||
} |
||||
|
||||
private void initPlayer(){ |
||||
videoReverse.setVideoPath(VIDEO_REVERSE_PATH); |
||||
} |
||||
|
||||
/** |
||||
* 开始视频倒播 |
||||
*/ |
||||
private void startPlay(){ |
||||
videoReverse.start(); |
||||
} |
||||
|
||||
/** |
||||
* 视频反序处理 |
||||
*/ |
||||
private void videoReverse(){ |
||||
if (!FileUtil.checkFileExist(VIDEO_NORMAL_PATH)){ |
||||
return; |
||||
} |
||||
String[] commandLine = FFmpegUtil.reverseVideo(VIDEO_NORMAL_PATH, VIDEO_REVERSE_PATH); |
||||
if (ffmpegHandler != null) { |
||||
ffmpegHandler.executeFFmpegCmd(commandLine); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
void onViewClick(View view) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
void onSelectedFile(String filePath) { |
||||
VIDEO_NORMAL_PATH = filePath; |
||||
loading.setVisibility(View.VISIBLE); |
||||
videoReverse(); |
||||
} |
||||
|
||||
@Override |
||||
protected void onDestroy() { |
||||
super.onDestroy(); |
||||
if (mHandler != null) { |
||||
mHandler.removeCallbacksAndMessages(null); |
||||
} |
||||
} |
||||
} |
@ -1,34 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:context="com.frank.ffmpeg.activity.VideoReverseActivity"> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/layout_loading" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_centerInParent="true" |
||||
android:orientation="vertical"> |
||||
<ProgressBar |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center_horizontal"/> |
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="10dp" |
||||
android:text="@string/converting_video" |
||||
android:textColor="@color/colorPrimary" |
||||
android:textSize="18sp"/> |
||||
</LinearLayout> |
||||
|
||||
<VideoView |
||||
android:id="@+id/video_reverse" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_centerInParent="true" |
||||
android:visibility="gone"/> |
||||
|
||||
</RelativeLayout> |
Loading…
Reference in new issue