From 2945132debfdbc2364877447d2d8a3d75f31f5c4 Mon Sep 17 00:00:00 2001
From: xufulong <839789740@qq.com>
Date: Tue, 5 Nov 2019 23:44:28 +0800
Subject: [PATCH] =?UTF-8?q?VideoPlayerActivity=E6=8E=A5=E5=85=A5=E5=9F=BA?=
=?UTF-8?q?=E7=B1=BBactivity?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 6 +-
.../ffmpeg/activity/VideoPlayerActivity.java | 101 ++++++++++--------
2 files changed, 58 insertions(+), 49 deletions(-)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 54bd080..9b628be 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,8 +36,7 @@
+ android:screenOrientation="landscape" />
+ android:screenOrientation="landscape" />
= 1/32){
- playRate *= 0.5;
- }
- Log.i(TAG, "playRate=" + playRate);
- videoPlayer.setPlayRate(playRate);
- }
- });
-
+ initViewsWithClick(R.id.btn_slow);
+ initViewsWithClick(R.id.btn_fast);
}
private void initPlayer(){
@@ -74,10 +52,24 @@ public class VideoPlayerActivity extends AppCompatActivity implements SurfaceHol
@Override
public void surfaceCreated(SurfaceHolder holder) {
+ surfaceCreated = true;
+ }
+
+ @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)){
+ if (!FileUtil.checkFileExist(filePath)) {
return;
}
@@ -87,20 +79,39 @@ public class VideoPlayerActivity extends AppCompatActivity implements SurfaceHol
}
@Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
-
+ protected void onDestroy() {
+ super.onDestroy();
+ if(videoPlayer != null){
+ videoPlayer = null;
+ }
}
@Override
- public void surfaceDestroyed(SurfaceHolder holder) {
-
+ 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
- protected void onDestroy() {
- super.onDestroy();
- if(videoPlayer != null){
- videoPlayer = null;
+ void onSelectedFile(String filePath) {
+ if (surfaceCreated) {
+ startPlay(filePath);
}
}