remove VideoPlayer

remove VideoPlayer
pull/107/head
xufulong 5 years ago
parent 7c4b591ef3
commit 3e8442ce4a
  1. 4
      app/src/main/AndroidManifest.xml
  2. 7
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java
  3. 125
      app/src/main/java/com/frank/ffmpeg/activity/VideoPlayerActivity.java
  4. 7
      app/src/main/res/layout/activity_video_handle.xml
  5. 31
      app/src/main/res/layout/activity_video_player.xml

@ -33,10 +33,6 @@
<activity android:name=".activity.MediaHandleActivity" /> <activity android:name=".activity.MediaHandleActivity" />
<!-- 视频处理 --> <!-- 视频处理 -->
<activity android:name=".activity.VideoHandleActivity" /> <activity android:name=".activity.VideoHandleActivity" />
<!-- 视频解码播放 -->
<activity
android:name=".activity.VideoPlayerActivity"
android:screenOrientation="landscape" />
<!-- 音视频解码播放 --> <!-- 音视频解码播放 -->
<activity <activity
android:name=".activity.MediaPlayerActivity" android:name=".activity.MediaPlayerActivity"

@ -1,7 +1,6 @@
package com.frank.ffmpeg.activity; package com.frank.ffmpeg.activity;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
@ -74,7 +73,6 @@ public class VideoHandleActivity extends BaseActivity {
R.id.btn_generate_gif, R.id.btn_generate_gif,
R.id.btn_screen_record, R.id.btn_screen_record,
R.id.btn_combine_video, R.id.btn_combine_video,
R.id.btn_play_video,
R.id.btn_multi_video, R.id.btn_multi_video,
R.id.btn_reverse_video, R.id.btn_reverse_video,
R.id.btn_denoise_video, R.id.btn_denoise_video,
@ -175,11 +173,6 @@ public class VideoHandleActivity extends BaseActivity {
String combineVideo = PATH + File.separator + "combineVideo.mp4"; String combineVideo = PATH + File.separator + "combineVideo.mp4";
commandLine = FFmpegUtil.pictureToVideo(picturePath, combineVideo); commandLine = FFmpegUtil.pictureToVideo(picturePath, combineVideo);
break; break;
case R.id.btn_play_video://视频解码播放
Intent playIntent = new Intent(VideoHandleActivity.this, VideoPlayerActivity.class);
playIntent.putExtra("videoHandlePath", srcFile);
startActivity(playIntent);
return;
case R.id.btn_multi_video://视频画面拼接:分辨率、时长、封装格式不一致时,先把视频源转为一致 case R.id.btn_multi_video://视频画面拼接:分辨率、时长、封装格式不一致时,先把视频源转为一致
String input1 = PATH + File.separator + "input1.mp4"; String input1 = PATH + File.separator + "input1.mp4";
String input2 = PATH + File.separator + "input2.mp4"; String input2 = PATH + File.separator + "input2.mp4";

@ -1,125 +0,0 @@
package com.frank.ffmpeg.activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import com.frank.ffmpeg.R;
import com.frank.ffmpeg.VideoPlayer;
import com.frank.ffmpeg.util.FileUtil;
/**
* 使用ffmpeg播放视频
* Created by frank on 2018/2/1.
*/
public class VideoPlayerActivity extends BaseActivity implements SurfaceHolder.Callback {
private static final String TAG = VideoPlayerActivity.class.getSimpleName();
SurfaceHolder surfaceHolder;
private VideoPlayer videoPlayer;
//播放倍率
private float playRate = 1;
private boolean surfaceCreated;
private String videoPath;
@Override
int getLayoutId() {
return R.layout.activity_video_player;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
videoPath = getIntent().getStringExtra("videoHandlePath");
initView();
initPlayer();
showToast(getString(R.string.please_click_select));
}
private void initView() {
SurfaceView surfaceView = getView(R.id.surface_view);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
initViewsWithClick(R.id.btn_slow);
initViewsWithClick(R.id.btn_fast);
}
private void initPlayer(){
videoPlayer = new VideoPlayer();
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
surfaceCreated = true;
if (!TextUtils.isEmpty(videoPath)) {
startPlay(videoPath);
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
private void startPlay(final String filePath) {
new Thread(new Runnable() {
@Override
public void run() {
if (!FileUtil.checkFileExist(filePath)) {
return;
}
videoPlayer.play(filePath, surfaceHolder.getSurface());
}
}).start();
}
@Override
protected void onDestroy() {
super.onDestroy();
if(videoPlayer != null){
videoPlayer = null;
}
}
@Override
void onViewClick(View view) {
switch (view.getId()) {
case R.id.btn_fast:
if(playRate >= 1/32){
playRate *= 0.5;
}
Log.i(TAG, "fast playRate=" + playRate);
videoPlayer.setPlayRate(playRate);
break;
case R.id.btn_slow:
if(playRate <= 32){
playRate *= 2;
}
Log.i(TAG, "slow playRate=" + playRate);
videoPlayer.setPlayRate(playRate);
break;
default:
break;
}
}
@Override
void onSelectedFile(String filePath) {
if (surfaceCreated) {
startPlay(filePath);
}
}
}

@ -79,13 +79,6 @@
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:text="@string/video_from_photo"/> android:text="@string/video_from_photo"/>
<Button
android:id="@+id/btn_play_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/video_play"/>
<Button <Button
android:id="@+id/btn_multi_video" android:id="@+id/btn_multi_video"
android:layout_width="wrap_content" android:layout_width="wrap_content"

@ -1,31 +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.VideoPlayerActivity">
<SurfaceView
android:id="@+id/surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/btn_slow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_margin="16dp"
android:text="@string/video_slow"/>
<Button
android:id="@+id/btn_fast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="16dp"
android:text="@string/video_fast"/>
</RelativeLayout>
Loading…
Cancel
Save