去掉倒播activity

去掉倒播activity
pull/107/head
xufulong 5 years ago
parent a7c47023e2
commit 4f08770cf0
  1. 3
      app/src/main/AndroidManifest.xml
  2. 2
      app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.java
  3. 4
      app/src/main/java/com/frank/ffmpeg/activity/MainActivity.java
  4. 118
      app/src/main/java/com/frank/ffmpeg/activity/VideoReverseActivity.java
  5. 11
      app/src/main/res/layout/activity_main.xml
  6. 3
      app/src/main/res/layout/activity_video_handle.xml
  7. 34
      app/src/main/res/layout/activity_video_reverse.xml

@ -48,9 +48,6 @@
<activity
android:name=".activity.FilterActivity"
android:screenOrientation="landscape" />
<!--视频倒播-->
<activity android:name=".activity.VideoReverseActivity"
android:screenOrientation="landscape" />
<!--视频播放拖动预览-->
<activity android:name=".activity.VideoPreviewActivity"
android:screenOrientation="portrait" />

@ -28,7 +28,7 @@ import com.frank.live.param.VideoParam;
public class LiveActivity extends BaseActivity implements CompoundButton.OnCheckedChangeListener, LiveStateChangeListener {
private final static String TAG = LiveActivity.class.getSimpleName();
private final static String LIVE_URL = "rtmp://192.168.1.102/live/stream";
private final static String LIVE_URL = "rtmp://192.168.1.3/live/stream";
private final static int MSG_ERROR = 100;
private SurfaceHolder surfaceHolder;
private LivePusher livePusher;

@ -30,7 +30,6 @@ public class MainActivity extends BaseActivity {
R.id.btn_push,
R.id.btn_live,
R.id.btn_filter,
R.id.btn_reverse,
R.id.btn_preview
);
}
@ -60,9 +59,6 @@ public class MainActivity extends BaseActivity {
case R.id.btn_filter://滤镜特效
intent.setClass(MainActivity.this, FilterActivity.class);
break;
case R.id.btn_reverse://视频倒播
intent.setClass(MainActivity.this, VideoReverseActivity.class);
break;
case R.id.btn_preview://视频拖动实时预览
intent.setClass(MainActivity.this, VideoPreviewActivity.class);
break;

@ -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);
}
}
}

@ -65,15 +65,6 @@
android:layout_centerHorizontal="true"
android:layout_below="@+id/btn_live"/>
<Button
android:id="@+id/btn_reverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/video_reverse"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/btn_filter"/>
<Button
android:id="@+id/btn_preview"
android:layout_width="wrap_content"
@ -81,6 +72,6 @@
android:text="@string/video_preview"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/btn_reverse"/>
android:layout_below="@+id/btn_filter"/>
</RelativeLayout>

@ -14,7 +14,8 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginTop="20dp">
<LinearLayout
android:id="@+id/layout_video_handle"
android:layout_width="match_parent"

@ -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…
Cancel
Save