|
@@ -2,9 +2,11 @@ package com.cooleshow.base.ui.video;
|
|
|
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
+import android.graphics.drawable.AnimationDrawable;
|
|
|
import android.media.MediaPlayer;
|
|
|
import android.net.Uri;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.MediaController;
|
|
|
|
|
@@ -23,6 +25,8 @@ public class VideoPlayActivity extends BaseActivity<ActivityVideoPlayLayoutBindi
|
|
|
public static final String VIDEO_PATH_KEY = "video_path";
|
|
|
private MediaController mMediaController;
|
|
|
|
|
|
+ private AnimationDrawable animDrawable;
|
|
|
+
|
|
|
public static void start(Context context, String videoPath) {
|
|
|
Intent intent = new Intent(context, VideoPlayActivity.class);
|
|
|
intent.putExtra(VIDEO_PATH_KEY, videoPath);
|
|
@@ -38,6 +42,8 @@ public class VideoPlayActivity extends BaseActivity<ActivityVideoPlayLayoutBindi
|
|
|
finish();
|
|
|
return;
|
|
|
}
|
|
|
+ animDrawable = (AnimationDrawable) viewBinding.ivLoading.getBackground();
|
|
|
+ showVideoLoading();
|
|
|
viewBinding.ivIconBack.setOnClickListener(this);
|
|
|
viewBinding.videoView.setVideoPath(videoPath);
|
|
|
viewBinding.videoView.requestFocus();
|
|
@@ -49,6 +55,20 @@ public class VideoPlayActivity extends BaseActivity<ActivityVideoPlayLayoutBindi
|
|
|
viewBinding.videoView.start();
|
|
|
}
|
|
|
|
|
|
+ private void showVideoLoading() {
|
|
|
+ viewBinding.flProgress.setVisibility(View.VISIBLE);
|
|
|
+ if (animDrawable != null) {
|
|
|
+ animDrawable.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void hideVideoLoading(){
|
|
|
+ if (animDrawable != null) {
|
|
|
+ animDrawable.stop();
|
|
|
+ }
|
|
|
+ viewBinding.flProgress.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected ActivityVideoPlayLayoutBinding getLayoutView() {
|
|
|
return ActivityVideoPlayLayoutBinding.inflate(getLayoutInflater());
|
|
@@ -62,6 +82,8 @@ public class VideoPlayActivity extends BaseActivity<ActivityVideoPlayLayoutBindi
|
|
|
*/
|
|
|
@Override
|
|
|
public void onPrepared(MediaPlayer mp) {
|
|
|
+ Log.i("pq","Thread:"+Thread.currentThread().getName());
|
|
|
+ hideVideoLoading();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,6 +107,8 @@ public class VideoPlayActivity extends BaseActivity<ActivityVideoPlayLayoutBindi
|
|
|
@Override
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) {
|
|
|
ToastUtil.getInstance().showShort("视频加载失败");
|
|
|
+ Log.i("pq"," onError Thread:"+Thread.currentThread().getName());
|
|
|
+ hideVideoLoading();
|
|
|
return false;
|
|
|
}
|
|
|
|