|
|
@@ -0,0 +1,534 @@
|
|
|
+package com.sheep.gamegroup.view.activity;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.Context;
|
|
|
+import android.media.AudioManager;
|
|
|
+import android.media.MediaPlayer;
|
|
|
+import android.net.Uri;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.design.widget.CheckableImageButton;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v7.widget.AppCompatCheckedTextView;
|
|
|
+import android.text.TextUtils;
|
|
|
+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.TextView;
|
|
|
+import android.widget.VideoView;
|
|
|
+
|
|
|
+import com.kfzs.duanduan.utils.StatusBarUtils;
|
|
|
+import com.sheep.gamegroup.absBase.BaseContainerActivity;
|
|
|
+import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
+import com.sheep.gamegroup.model.entity.DiscoveryVideo;
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
+import com.sheep.gamegroup.util.ApiUtil;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
+import com.sheep.gamegroup.util.Jump2View;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.TestUtil;
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
+import com.sheep.gamegroup.util.share.CommonUMShareListener;
|
|
|
+import com.sheep.gamegroup.util.share.ShareLinkConfig;
|
|
|
+import com.sheep.gamegroup.view.fragment.FgtVideoComment;
|
|
|
+import com.sheep.jiuyan.samllsheep.R;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
+
|
|
|
+import butterknife.BindView;
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by realicing on 2018/11/9.
|
|
|
+ * realicing@sina.com
|
|
|
+ * 小绵羊3.4.5新增 -- 视频详情
|
|
|
+ */
|
|
|
+public class ActPlayVideoArticle extends BaseContainerActivity implements MediaPlayer.OnInfoListener, MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, View.OnLayoutChangeListener {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ StatusBarUtils.setTranslucent(this);
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ }
|
|
|
+
|
|
|
+ //播放
|
|
|
+ @BindView(R.id.videoView)
|
|
|
+ VideoView videoView;
|
|
|
+ @BindView(R.id.video_loading)
|
|
|
+ View video_loading;
|
|
|
+
|
|
|
+ //top
|
|
|
+ @BindView(R.id.video_top)
|
|
|
+ View video_top;
|
|
|
+ @BindView(R.id.video_camera_iv)
|
|
|
+ ImageView video_camera_iv;
|
|
|
+ @BindView(R.id.video_avatar_iv)
|
|
|
+ ImageView video_avatar_iv;
|
|
|
+ @BindView(R.id.video_focus_iv)
|
|
|
+ CheckableImageButton video_focus_iv;
|
|
|
+
|
|
|
+ //bottom
|
|
|
+ @BindView(R.id.video_bottom)
|
|
|
+ View video_bottom;
|
|
|
+ @BindView(R.id.video_like_tv)
|
|
|
+ AppCompatCheckedTextView video_like_tv;
|
|
|
+ @BindView(R.id.video_comment_tv)
|
|
|
+ TextView video_comment_tv;
|
|
|
+ @BindView(R.id.video_share_tv)
|
|
|
+ TextView video_share_tv;
|
|
|
+ @BindView(R.id.video_title_tv)
|
|
|
+ TextView video_title_tv;
|
|
|
+
|
|
|
+ @BindView(R.id.frame_container)
|
|
|
+ View frame_container;
|
|
|
+
|
|
|
+ //评论
|
|
|
+ private FgtVideoComment fgtVideoComment;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayoutId() {
|
|
|
+ return R.layout.act_play_video_article;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int video_id;
|
|
|
+ private int user_id;
|
|
|
+ private String video_url;
|
|
|
+ private DiscoveryVideo newVideo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initView() {
|
|
|
+ super.initView();
|
|
|
+ initVolume();
|
|
|
+ DiscoveryVideo lastVideo = DataUtil.getObject(getIntent(), DiscoveryVideo.class);
|
|
|
+ if (lastVideo == null) {
|
|
|
+ video_id = DataUtil.getObject(getIntent(), Integer.class);
|
|
|
+ fgtVideoComment.setVideo_id(video_id);
|
|
|
+ loadVideoData(null);
|
|
|
+ } else {
|
|
|
+ video_id = lastVideo.getId();
|
|
|
+ fgtVideoComment.setVideo_id(video_id);
|
|
|
+ user_id = lastVideo.getUser_id();
|
|
|
+ video_url = lastVideo.getResource();
|
|
|
+ loadVideoData(lastVideo);
|
|
|
+ }
|
|
|
+ ViewUtil.setImage(video_camera_iv, ViewUtil.getNetImgByName("add_article_camera"));
|
|
|
+ ViewUtil.setVisibility2(frame_container, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Fragment initFragment() {
|
|
|
+ fgtVideoComment = new FgtVideoComment();
|
|
|
+ return fgtVideoComment;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void loadVideoData(DiscoveryVideo video) {
|
|
|
+ if (fgtVideoComment != null)
|
|
|
+ fgtVideoComment.loadVideoData(video);
|
|
|
+ if (video == null) {
|
|
|
+ ViewUtil.setText(video_like_tv, ViewUtil.BLOCK);
|
|
|
+ ViewUtil.setText(video_comment_tv, ViewUtil.BLOCK);
|
|
|
+ ViewUtil.setText(video_title_tv, ViewUtil.BLOCK);
|
|
|
+ ViewUtil.setText(video_share_tv, ViewUtil.BLOCK);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ViewUtil.setAvatar(video_avatar_iv, video.getAvatar());
|
|
|
+ ViewUtil.setText(video_like_tv, video.getLike());
|
|
|
+ ViewUtil.setText(video_comment_tv, video.getComment());
|
|
|
+ ViewUtil.setText(video_title_tv, video.getTitle());
|
|
|
+ ViewUtil.setText(video_share_tv, video.getShare());
|
|
|
+ ViewUtil.setChecked(video_like_tv, video.getIs_like());
|
|
|
+ ViewUtil.setChecked(video_focus_iv, video.getIs_like());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initPlay() {
|
|
|
+ Uri uri = Uri.parse(SheepApp.getHttpProxyCacheServer().getProxyUrl(video_url));
|
|
|
+ videoView.setOnInfoListener(this);
|
|
|
+ videoView.setOnPreparedListener(this);
|
|
|
+ videoView.setOnErrorListener(this);
|
|
|
+ videoView.setOnCompletionListener(this);
|
|
|
+ videoView.addOnLayoutChangeListener(this);
|
|
|
+ videoView.setMediaController(new MediaController(this));
|
|
|
+ videoView.setVideoURI(uri);
|
|
|
+ }
|
|
|
+
|
|
|
+ //点赞
|
|
|
+ public void onClickVideoLike(View view) {
|
|
|
+ ViewUtil.setEnabled(video_like_tv, false);
|
|
|
+ ApiUtil.postVideoLike(video_id, new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ if (newVideo != null) {
|
|
|
+ G.showToast(newVideo.getIs_like() ? R.string.cancel_like_success : R.string.like_success);
|
|
|
+ newVideo.setLike(newVideo.getLike() + (newVideo.getIs_like() ? -1 : 1));
|
|
|
+ newVideo.setIs_like(!newVideo.getIs_like());
|
|
|
+ ViewUtil.setText(video_like_tv, newVideo.getLike());
|
|
|
+ ViewUtil.setChecked(video_like_tv, newVideo.getIs_like());
|
|
|
+ } else {
|
|
|
+ G.showToast("操作成功");
|
|
|
+ }
|
|
|
+ ViewUtil.setEnabled(video_like_tv, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ if (newVideo != null) {
|
|
|
+ G.showToast(newVideo.getIs_like() ? R.string.cancel_like_fail : R.string.like_fail);
|
|
|
+ } else {
|
|
|
+ G.showToast("操作失败");
|
|
|
+ }
|
|
|
+ ViewUtil.setEnabled(video_like_tv, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //评论
|
|
|
+ public void onClickVideoComment(View view) {
|
|
|
+ ViewUtil.setVisibility(frame_container, true);
|
|
|
+ ViewUtil.setVisibility(video_bottom, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ShareLinkConfig shareLinkConfig;
|
|
|
+
|
|
|
+ //分享
|
|
|
+ public void onClickVideoShare(View view) {
|
|
|
+ if (shareLinkConfig == null)
|
|
|
+ shareLinkConfig = new ShareLinkConfig();
|
|
|
+ if (newVideo != null) {
|
|
|
+ shareLinkConfig.setDes(newVideo.getTitle());
|
|
|
+ }
|
|
|
+ shareLinkConfig.toShare(this, new CommonUMShareListener() {
|
|
|
+ @Override
|
|
|
+ public void onResult(SHARE_MEDIA share_media) {
|
|
|
+ ApiUtil.postVideoShare(video_id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //点击头像跳转用户游戏主页
|
|
|
+ public void onClickAvatar(View view) {
|
|
|
+ if (user_id > 0)
|
|
|
+ Jump2View.getInstance().goActUserAppHome(this, user_id);
|
|
|
+ else
|
|
|
+ G.showToast(R.string.loading_data);
|
|
|
+ }
|
|
|
+
|
|
|
+ //点击头像下面的+进行关注
|
|
|
+ public void onClickVideoFocus(View view) {
|
|
|
+ if (user_id > 0) {
|
|
|
+ ViewUtil.setEnabled(video_focus_iv, false);
|
|
|
+ ApiUtil.postGameUserFocusUser(user_id, new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ if (newVideo != null) {
|
|
|
+ G.showToast(newVideo.isIs_focus_user() ? R.string.cancel_focus_success : R.string.focus_success);
|
|
|
+ newVideo.setIs_focus_user(!newVideo.isIs_focus_user());
|
|
|
+ ViewUtil.setChecked(video_focus_iv, newVideo.isIs_focus_user());
|
|
|
+ } else {
|
|
|
+ G.showToast("操作成功");
|
|
|
+ }
|
|
|
+ ViewUtil.setEnabled(video_focus_iv, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ if (newVideo != null) {
|
|
|
+ G.showToast(newVideo.isIs_focus_user() ? R.string.cancel_focus_fail : R.string.focus_fail);
|
|
|
+ } else {
|
|
|
+ G.showToast("操作失败");
|
|
|
+ }
|
|
|
+ ViewUtil.setEnabled(video_focus_iv, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ G.showToast(R.string.loading_data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onBackPressed() {
|
|
|
+ if (ViewUtil.isVisible(frame_container)) {
|
|
|
+ ViewUtil.setVisibility(frame_container, false);
|
|
|
+ ViewUtil.setVisibility(video_bottom, true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ super.onBackPressed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
+ @Override
|
|
|
+ public void initListener() {
|
|
|
+ initPlay();
|
|
|
+ mGestureDetector = new GestureDetector(getApplicationContext(), mGestureListener);
|
|
|
+ View.OnTouchListener listener = new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ return onTouchEvent(event);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ videoView.setOnTouchListener(listener);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initData() {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getVideoDetail(video_id)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ newVideo = baseMessage.getData(DiscoveryVideo.class);
|
|
|
+ if (newVideo != null) {
|
|
|
+ user_id = newVideo.getUser_id();
|
|
|
+ if (TextUtils.isEmpty(video_url)) {
|
|
|
+ video_url = newVideo.getResource();
|
|
|
+ initPlay();
|
|
|
+ }
|
|
|
+ loadVideoData(newVideo);
|
|
|
+ if (fgtVideoComment != null)
|
|
|
+ fgtVideoComment.refreshData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ if (TestUtil.isDev()) G.showToast(baseMessage);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private GestureDetector mGestureDetector;
|
|
|
+
|
|
|
+ //播放或者暂停
|
|
|
+ private void playOrPause() {
|
|
|
+ if (videoView.isPlaying()) {
|
|
|
+ pause();
|
|
|
+ } else {
|
|
|
+ play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //播放
|
|
|
+ private void play() {
|
|
|
+ if (videoView == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ videoView.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ //暂停
|
|
|
+ private void pause() {
|
|
|
+ if (videoView == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ videoView.pause();
|
|
|
+ }
|
|
|
+
|
|
|
+ //销毁
|
|
|
+ private void destroy() {
|
|
|
+ if (videoView == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ videoView.stopPlayback();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onTouchEvent(MotionEvent event) {
|
|
|
+ return mGestureDetector.onTouchEvent(event);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ if (!isPauseByUser)
|
|
|
+ play();
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否是用户手机暂停
|
|
|
+ private boolean isPauseByUser;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPause() {
|
|
|
+ super.onPause();
|
|
|
+ if (videoView != null && videoView.isPlaying())
|
|
|
+ isPauseByUser = false;
|
|
|
+ if (video_loading != null)
|
|
|
+ video_loading.setVisibility(View.VISIBLE);
|
|
|
+ pause();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ destroy();
|
|
|
+ }
|
|
|
+
|
|
|
+ // //滑动方向
|
|
|
+// private int direction = 0;
|
|
|
+// //左右滑动
|
|
|
+// public static final int DIRECTION_LEFT_RIGHT = 1;
|
|
|
+// //上下滑动
|
|
|
+// public static final int DIRECTION_TOP_BOTTOM = 2;
|
|
|
+ private GestureDetector.SimpleOnGestureListener mGestureListener = new GestureDetector.SimpleOnGestureListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onDown(MotionEvent e) {
|
|
|
+ LogUtil.println("mGestureListener", "onDown");
|
|
|
+// direction = 0;
|
|
|
+ return super.onDown(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLongPress(MotionEvent e) {
|
|
|
+ LogUtil.println("mGestureListener", "onLongPress");
|
|
|
+ super.onLongPress(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onSingleTapConfirmed(MotionEvent e) {
|
|
|
+ LogUtil.println("mGestureListener", "onSingleTapConfirmed");
|
|
|
+ ViewUtil.toggleVisibility(video_top);
|
|
|
+ ViewUtil.setVisibility(video_bottom, ViewUtil.isVisible(video_top));
|
|
|
+ ViewUtil.setVisibility(frame_container, false);
|
|
|
+// if(isPlaying)
|
|
|
+// isPauseByUser = true;
|
|
|
+// playOrPause();
|
|
|
+ return super.onSingleTapConfirmed(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
|
|
+ float distanceX, float distanceY) {
|
|
|
+ float mOldX = e1.getX(), mOldY = e1.getY();
|
|
|
+ int y = (int) e2.getRawY();
|
|
|
+ int windowWidth = ActPlayVideoArticle.this.windowWidth;
|
|
|
+ int windowHeight = ActPlayVideoArticle.this.windowHeight;
|
|
|
+ int lineMiddle = windowWidth / 2;
|
|
|
+ if (mOldX > lineMiddle)// 左边滑动
|
|
|
+ onBrightnessSlide((mOldY - y) / windowHeight);
|
|
|
+ else if (mOldX < lineMiddle)// 右边滑动
|
|
|
+ onVolumeSlide((mOldY - y) / windowHeight);
|
|
|
+ return super.onScroll(e1, e2, distanceX, distanceY);
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+ private AudioManager mAudioManager;
|
|
|
+ private int mMaxVolume;//最大音量
|
|
|
+ private int mVolume;//当前音量
|
|
|
+
|
|
|
+ private void initVolume() {
|
|
|
+ mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
|
|
+ if (mAudioManager != null)
|
|
|
+ mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
|
|
+ }
|
|
|
+
|
|
|
+ //滑动改变音量
|
|
|
+ private void onVolumeSlide(float percent) {
|
|
|
+ if (mVolume == -1) {
|
|
|
+ mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
|
|
+ if (mVolume < 0)
|
|
|
+ mVolume = 0;
|
|
|
+
|
|
|
+ // 显示
|
|
|
+// mOperationBg.setImageResource(R.drawable.video_volumn_bg);
|
|
|
+// mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = (int) (percent * mMaxVolume) + mVolume;
|
|
|
+ if (index > mMaxVolume)
|
|
|
+ index = mMaxVolume;
|
|
|
+ else if (index < 0)
|
|
|
+ index = 0;
|
|
|
+
|
|
|
+ // 变更声音
|
|
|
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
|
|
|
+ // 变更进度条
|
|
|
+// ViewGroup.LayoutParams lp = mOperationPercent.getLayoutParams();
|
|
|
+// lp.width = findViewById(R.id.operation_full).getLayoutParams().width * index / mMaxVolume;
|
|
|
+// mOperationPercent.setLayoutParams(lp);
|
|
|
+ }
|
|
|
+
|
|
|
+ private float mBrightness = -1;
|
|
|
+
|
|
|
+ //滑动改变亮度
|
|
|
+ private void onBrightnessSlide(float percent) {
|
|
|
+ if (mBrightness < 0) {
|
|
|
+ mBrightness = getWindow().getAttributes().screenBrightness;
|
|
|
+ if (mBrightness <= 0.00f)
|
|
|
+ mBrightness = 0.50f;
|
|
|
+ if (mBrightness < 0.01f)
|
|
|
+ mBrightness = 0.01f;
|
|
|
+
|
|
|
+ // 显示
|
|
|
+// mOperationBg.setImageResource(R.drawable.video_brightness_bg);
|
|
|
+// mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ WindowManager.LayoutParams lpa = getWindow().getAttributes();
|
|
|
+ lpa.screenBrightness = mBrightness + percent;
|
|
|
+ if (lpa.screenBrightness > 1.0f)
|
|
|
+ lpa.screenBrightness = 1.0f;
|
|
|
+ else if (lpa.screenBrightness < 0.01f)
|
|
|
+ lpa.screenBrightness = 0.01f;
|
|
|
+ getWindow().setAttributes(lpa);
|
|
|
+
|
|
|
+// ViewGroup.LayoutParams lp = mOperationPercent.getLayoutParams();
|
|
|
+// lp.width = (int) (findViewById(R.id.operation_full).getLayoutParams().width * lpa.screenBrightness);
|
|
|
+// mOperationPercent.setLayoutParams(lp);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onInfo(MediaPlayer mediaPlayer, int what, int extra) {
|
|
|
+ LogUtil.println("ActPlayVideo", "onInfo what = " + what + " extra = " + extra);
|
|
|
+ if (!mediaPlayer.isLooping())
|
|
|
+ mediaPlayer.setLooping(true);
|
|
|
+ switch (what) {
|
|
|
+ case MediaPlayer.MEDIA_INFO_BUFFERING_START:
|
|
|
+ LogUtil.println("ActPlayVideo", "onInfo", "正在缓冲");
|
|
|
+ if (video_loading != null)
|
|
|
+ video_loading.setVisibility(View.VISIBLE);
|
|
|
+ break;
|
|
|
+ case MediaPlayer.MEDIA_INFO_BUFFERING_END:
|
|
|
+ case MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
|
|
|
+ LogUtil.println("ActPlayVideo", "onInfo", "缓冲完成");
|
|
|
+ //缓存完成,继续播放
|
|
|
+ if (video_loading != null)
|
|
|
+ video_loading.setVisibility(View.GONE);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPrepared(MediaPlayer mediaPlayer) {
|
|
|
+ LogUtil.println("ActPlayVideo", "onPrepared");
|
|
|
+ if (video_loading != null)
|
|
|
+ video_loading.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
|
|
|
+ LogUtil.println("ActPlayVideo", "onInfo what = " + what + " extra = " + extra);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCompletion(MediaPlayer mediaPlayer) {
|
|
|
+ LogUtil.println("ActPlayVideo", "onCompletion");
|
|
|
+ }
|
|
|
+
|
|
|
+ private int windowWidth = G.WIDTH;
|
|
|
+ private int windowHeight = G.HEIGHT;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
|
|
+ LogUtil.println("ActPlayVideo", "onLayoutChange", left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom);
|
|
|
+ this.windowWidth = left + right;
|
|
|
+ this.windowHeight = top + bottom;
|
|
|
+ }
|
|
|
+}
|