|
|
@@ -10,7 +10,7 @@ import android.view.GestureDetector;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
-import android.widget.ImageView;
|
|
|
+import android.widget.MediaController;
|
|
|
import android.widget.VideoView;
|
|
|
|
|
|
import com.kfzs.duanduan.utils.StatusBarUtils;
|
|
|
@@ -37,8 +37,6 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
|
|
|
|
|
|
@BindView(R.id.videoView)
|
|
|
VideoView videoView;
|
|
|
- @BindView(R.id.play_or_pause)
|
|
|
- ImageView play_or_pause;
|
|
|
@BindView(R.id.video_loading)
|
|
|
View video_loading;
|
|
|
|
|
|
@@ -57,6 +55,7 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
|
|
|
videoView.setOnErrorListener(this);
|
|
|
videoView.setOnCompletionListener(this);
|
|
|
videoView.addOnLayoutChangeListener(this);
|
|
|
+ videoView.setMediaController(new MediaController(this));
|
|
|
videoView.setVideoURI(uri);
|
|
|
}
|
|
|
|
|
|
@@ -73,10 +72,9 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
|
|
|
}
|
|
|
private GestureDetector mGestureDetector;
|
|
|
|
|
|
- private boolean isPlaying;
|
|
|
//播放或者暂停
|
|
|
private void playOrPause() {
|
|
|
- if(isPlaying){
|
|
|
+ if(videoView.isPlaying()){
|
|
|
pause();
|
|
|
} else {
|
|
|
play();
|
|
|
@@ -87,27 +85,21 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
|
|
|
if(videoView == null){
|
|
|
return;
|
|
|
}
|
|
|
- play_or_pause.setVisibility(View.GONE);
|
|
|
videoView.start();
|
|
|
- isPlaying = true;
|
|
|
}
|
|
|
//暂停
|
|
|
private void pause(){
|
|
|
if(videoView == null){
|
|
|
return;
|
|
|
}
|
|
|
- play_or_pause.setVisibility(View.VISIBLE);
|
|
|
videoView.pause();
|
|
|
- isPlaying = false;
|
|
|
}
|
|
|
//销毁
|
|
|
private void destroy(){
|
|
|
if(videoView == null){
|
|
|
return;
|
|
|
}
|
|
|
- play_or_pause.setVisibility(View.VISIBLE);
|
|
|
videoView.stopPlayback();
|
|
|
- isPlaying = false;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -127,8 +119,10 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
|
|
|
@Override
|
|
|
protected void onPause() {
|
|
|
super.onPause();
|
|
|
- if(isPlaying)
|
|
|
+ if(videoView != null && videoView.isPlaying())
|
|
|
isPauseByUser = false;
|
|
|
+ if(video_loading != null)
|
|
|
+ video_loading.setVisibility(View.VISIBLE);
|
|
|
pause();
|
|
|
}
|
|
|
|
|
|
@@ -161,9 +155,9 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
|
|
|
@Override
|
|
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
|
|
LogUtil.println("mGestureListener", "onSingleTapConfirmed");
|
|
|
- if(isPlaying)
|
|
|
- isPauseByUser = true;
|
|
|
- playOrPause();
|
|
|
+// if(isPlaying)
|
|
|
+// isPauseByUser = true;
|
|
|
+// playOrPause();
|
|
|
return super.onSingleTapConfirmed(e);
|
|
|
}
|
|
|
@Override
|