fix [修复-视频播放问题]
This commit is contained in:
parent
97c692d41d
commit
ddaed22630
@ -15,6 +15,7 @@ import com.google.android.exoplayer2.PlaybackException;
|
|||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
import com.google.android.exoplayer2.ui.StyledPlayerView;
|
import com.google.android.exoplayer2.ui.StyledPlayerView;
|
||||||
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import com.yunbao.common.bean.ActiveBean;
|
import com.yunbao.common.bean.ActiveBean;
|
||||||
import com.yunbao.common.utils.L;
|
import com.yunbao.common.utils.L;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
@ -57,14 +58,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void intiPlayView() {
|
private void intiPlayView() {
|
||||||
DefaultLoadControl control = new DefaultLoadControl.Builder()
|
DefaultLoadControl control = new DefaultLoadControl.Builder().setPrioritizeTimeOverSizeThresholds(false).setBackBuffer(10_000, true).setBufferDurationsMs(500, 5_000, 150, 200).build();
|
||||||
.setPrioritizeTimeOverSizeThresholds(false)
|
|
||||||
.setBackBuffer(10_000, true)
|
|
||||||
.setBufferDurationsMs(500,
|
|
||||||
5_000,
|
|
||||||
150,
|
|
||||||
200)
|
|
||||||
.build();
|
|
||||||
mPlayer = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
mPlayer = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
||||||
placeholderView = findViewById(com.yunbao.live.R.id.placeholderView);
|
placeholderView = findViewById(com.yunbao.live.R.id.placeholderView);
|
||||||
mPlayer = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
mPlayer = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
||||||
@ -87,10 +81,22 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
|
|||||||
case Player.STATE_ENDED://播放器完整播放了所有媒体。
|
case Player.STATE_ENDED://播放器完整播放了所有媒体。
|
||||||
replay();
|
replay();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoSizeChanged(VideoSize videoSize) {
|
||||||
|
Player.Listener.super.onVideoSizeChanged(videoSize);
|
||||||
|
if (mActionListener != null) {
|
||||||
|
mActionListener.onVideoSize(videoSize.height, videoSize.width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRenderedFirstFrame() {
|
||||||
|
Player.Listener.super.onRenderedFirstFrame();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerError(PlaybackException error) {
|
public void onPlayerError(PlaybackException error) {
|
||||||
Player.Listener.super.onPlayerError(error);
|
Player.Listener.super.onPlayerError(error);
|
||||||
@ -259,6 +265,8 @@ public class VideoPlayViewHolder extends AbsViewHolder implements View.OnClickLi
|
|||||||
|
|
||||||
void onFirstFrame();
|
void onFirstFrame();
|
||||||
|
|
||||||
|
void onVideoSize(int height, int width);
|
||||||
|
|
||||||
void onProgress(int progress, int duration);
|
void onProgress(int progress, int duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ import java.util.List;
|
|||||||
public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnClickListener {
|
public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnClickListener {
|
||||||
|
|
||||||
private ViewGroup mVideoContainer;
|
private ViewGroup mVideoContainer;
|
||||||
private MyImageView mCover;
|
private ImageView mCover;
|
||||||
private ImageView mAvatar;
|
private ImageView mAvatar;
|
||||||
private TextView mName;
|
private TextView mName;
|
||||||
private TextView mTitle;
|
private TextView mTitle;
|
||||||
@ -101,7 +101,7 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
|
|||||||
progressCount = (TextView) findViewById(R.id.progressCount);
|
progressCount = (TextView) findViewById(R.id.progressCount);
|
||||||
|
|
||||||
mVideoContainer = (ViewGroup) findViewById(R.id.video_container);
|
mVideoContainer = (ViewGroup) findViewById(R.id.video_container);
|
||||||
mCover = (MyImageView) findViewById(R.id.cover);
|
mCover = (ImageView) findViewById(R.id.cover);
|
||||||
mAvatar = (ImageView) findViewById(R.id.avatar);
|
mAvatar = (ImageView) findViewById(R.id.avatar);
|
||||||
mName = (TextView) findViewById(R.id.name);
|
mName = (TextView) findViewById(R.id.name);
|
||||||
mTitle = (TextView) findViewById(R.id.title);
|
mTitle = (TextView) findViewById(R.id.title);
|
||||||
@ -303,20 +303,6 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
|
|||||||
mCover.requestLayout();
|
mCover.requestLayout();
|
||||||
}
|
}
|
||||||
mCover.setImageDrawable(drawable);
|
mCover.setImageDrawable(drawable);
|
||||||
|
|
||||||
/*
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
|
|
||||||
|
|
||||||
int imageWidth = drawable.getIntrinsicWidth();
|
|
||||||
int imageHeight = drawable.getIntrinsicHeight();
|
|
||||||
|
|
||||||
//宽度固定,然后根据原始宽高比得到此固定宽度需要的高度
|
|
||||||
//screenWidth 是屏幕宽度
|
|
||||||
int height = mCover.getWidth() * imageHeight / imageWidth;
|
|
||||||
ViewGroup.LayoutParams para = mCover.getLayoutParams();
|
|
||||||
para.height = height;
|
|
||||||
para.width = mCover.getWidth();*/
|
|
||||||
//mCover.setImageDrawable(drawable);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,6 +353,15 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSetVideoCoverSize(int height, int width) {
|
||||||
|
if (mCover != null) {
|
||||||
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
|
||||||
|
params.width = width;
|
||||||
|
params.height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 滑出屏幕
|
* 滑出屏幕
|
||||||
*/
|
*/
|
||||||
@ -529,20 +524,7 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli
|
|||||||
} else {
|
} else {
|
||||||
image = mVideoBean.getVideo() + "?vframe/jpg/offset/0";
|
image = mVideoBean.getVideo() + "?vframe/jpg/offset/0";
|
||||||
}
|
}
|
||||||
new SharePopDialog(mContext)
|
new SharePopDialog(mContext).setShareType(SharePopDialog.TYPE_VIDEO).setShareData(ShareBean.ShareBuilder.create().setShareType(SharePopDialog.TYPE_VIDEO).setUid(CommonAppConfig.getInstance().getUid()).setCover(StringUtil.isEmpty(image) ? mVideoBean.getUser_avatar() : image).setTitle(StringUtil.isEmpty(mVideoBean.getContent()) ? mVideoBean.getUser_name() : JSONObject.parseObject(mVideoBean.getContent()).getString("msg")).setAnchorId(mVideoBean.getUser_id()).setAnchorName(mVideoBean.getUser_name()).setAnchorAvatar(mVideoBean.getUser_avatar()).setExtraData(mVideoBean.getId()).build()).showDialog();
|
||||||
.setShareType(SharePopDialog.TYPE_VIDEO)
|
|
||||||
.setShareData(ShareBean.ShareBuilder.create()
|
|
||||||
.setShareType(SharePopDialog.TYPE_VIDEO)
|
|
||||||
.setUid(CommonAppConfig.getInstance().getUid())
|
|
||||||
.setCover(StringUtil.isEmpty(image) ? mVideoBean.getUser_avatar() : image)
|
|
||||||
.setTitle(StringUtil.isEmpty(mVideoBean.getContent()) ? mVideoBean.getUser_name() : JSONObject.parseObject(mVideoBean.getContent()).getString("msg"))
|
|
||||||
.setAnchorId(mVideoBean.getUser_id())
|
|
||||||
.setAnchorName(mVideoBean.getUser_name())
|
|
||||||
.setAnchorAvatar(mVideoBean.getUser_avatar())
|
|
||||||
.setExtraData(mVideoBean.getId())
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
.showDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
|
@ -241,6 +241,13 @@ public class VideoScrollViewHolder extends AbsViewHolder implements VideoScrollA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoSize(int height, int width) {
|
||||||
|
if (mVideoPlayWrapViewHolder != null) {
|
||||||
|
mVideoPlayWrapViewHolder.onSetVideoCoverSize(height, width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(int progress, int duration) {
|
public void onProgress(int progress, int duration) {
|
||||||
if (mVideoPlayWrapViewHolder != null) {
|
if (mVideoPlayWrapViewHolder != null) {
|
||||||
@ -318,7 +325,7 @@ public class VideoScrollViewHolder extends AbsViewHolder implements VideoScrollA
|
|||||||
*/
|
*/
|
||||||
private void openCommentInputWindow(boolean openFace) {
|
private void openCommentInputWindow(boolean openFace) {
|
||||||
if (mVideoBean != null) {
|
if (mVideoBean != null) {
|
||||||
((AbsVideoPlayActivity) mContext).openCommentInputWindowNew(openFace, mVideoBean.getId(), mVideoBean.getUser_id(), false,"",Integer.parseInt(mVideoBean.getComment_num()));
|
((AbsVideoPlayActivity) mContext).openCommentInputWindowNew(openFace, mVideoBean.getId(), mVideoBean.getUser_id(), false, "", Integer.parseInt(mVideoBean.getComment_num()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<com.yunbao.video.views.MyImageView
|
<ImageView
|
||||||
android:id="@+id/cover"
|
android:id="@+id/cover"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user