|
|
@ -2,7 +2,6 @@ package com.frank.ffmpeg.activity; |
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.media.MediaPlayer; |
|
|
|
import android.media.MediaPlayer; |
|
|
|
import android.os.Environment; |
|
|
|
|
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Message; |
|
|
|
import android.os.Message; |
|
|
@ -18,6 +17,8 @@ import com.frank.ffmpeg.view.VideoPreviewBar; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_TOAST; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 视频拖动实时预览 |
|
|
|
* 视频拖动实时预览 |
|
|
|
* Created by frank on 2019/11/16. |
|
|
|
* Created by frank on 2019/11/16. |
|
|
@ -27,13 +28,8 @@ public class VideoPreviewActivity extends BaseActivity implements VideoPreviewBa |
|
|
|
|
|
|
|
|
|
|
|
private final static String TAG = VideoPreviewActivity.class.getSimpleName(); |
|
|
|
private final static String TAG = VideoPreviewActivity.class.getSimpleName(); |
|
|
|
|
|
|
|
|
|
|
|
private final static String ROOT_PATH = Environment.getExternalStorageDirectory().getAbsolutePath(); |
|
|
|
|
|
|
|
private String videoPath = ROOT_PATH + "/What.mp4"; |
|
|
|
|
|
|
|
// private final static String videoPath = ROOT_PATH + "/bird-1080P.mkv";
|
|
|
|
|
|
|
|
// videoPath = "https://www.apple.com/105/media/cn/mac/family/2018/46c4b917_abfd_45a3_9b51_4e3054191797" +
|
|
|
|
|
|
|
|
// "/films/bruce/mac-bruce-tpl-cn-2018_1280x720h.mp4";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MediaPlayer mediaPlayer; |
|
|
|
private MediaPlayer mediaPlayer; |
|
|
|
|
|
|
|
private SurfaceView surfaceVideo; |
|
|
|
private VideoPreviewBar videoPreviewBar; |
|
|
|
private VideoPreviewBar videoPreviewBar; |
|
|
|
private final static int TIME_UPDATE = 1000; |
|
|
|
private final static int TIME_UPDATE = 1000; |
|
|
|
private final static int MSG_UPDATE = 1234; |
|
|
|
private final static int MSG_UPDATE = 1234; |
|
|
@ -48,6 +44,8 @@ public class VideoPreviewActivity extends BaseActivity implements VideoPreviewBa |
|
|
|
videoPreviewBar.updateProgress(mediaPlayer.getCurrentPosition()); |
|
|
|
videoPreviewBar.updateProgress(mediaPlayer.getCurrentPosition()); |
|
|
|
} |
|
|
|
} |
|
|
|
mHandler.sendEmptyMessageDelayed(MSG_UPDATE, TIME_UPDATE); |
|
|
|
mHandler.sendEmptyMessageDelayed(MSG_UPDATE, TIME_UPDATE); |
|
|
|
|
|
|
|
} else if (msg.what == MSG_TOAST) { |
|
|
|
|
|
|
|
showToast(getString(R.string.please_click_select)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -62,13 +60,12 @@ public class VideoPreviewActivity extends BaseActivity implements VideoPreviewBa |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
|
|
|
|
|
|
|
|
initView(); |
|
|
|
initView(); |
|
|
|
|
|
|
|
mHandler.sendEmptyMessageDelayed(MSG_TOAST, 500); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initView() { |
|
|
|
private void initView() { |
|
|
|
SurfaceView surfaceVideo = getView(R.id.surface_view); |
|
|
|
surfaceVideo = getView(R.id.surface_view); |
|
|
|
setPlayCallback(videoPath, surfaceVideo); |
|
|
|
|
|
|
|
videoPreviewBar = getView(R.id.preview_video); |
|
|
|
videoPreviewBar = getView(R.id.preview_video); |
|
|
|
videoPreviewBar.init(videoPath, this); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setPlayCallback(final String filePath, SurfaceView surfaceView) { |
|
|
|
private void setPlayCallback(final String filePath, SurfaceView surfaceView) { |
|
|
@ -127,7 +124,8 @@ public class VideoPreviewActivity extends BaseActivity implements VideoPreviewBa |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void onSelectedFile(String filePath) { |
|
|
|
void onSelectedFile(String filePath) { |
|
|
|
|
|
|
|
setPlayCallback(filePath, surfaceVideo); |
|
|
|
|
|
|
|
videoPreviewBar.init(filePath, this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|