修复通过【为你推荐】方式进入直播间会有上个直播间残留画面的问题
This commit is contained in:
parent
543336af99
commit
911869ed9f
@ -4,6 +4,8 @@ import android.content.Context;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
@ -25,8 +27,8 @@ import com.google.android.exoplayer2.video.VideoSize;
|
|||||||
public class LiveExoPlayerManager {
|
public class LiveExoPlayerManager {
|
||||||
private final int MODEL_PLAY1 = 0;//当前主播放器
|
private final int MODEL_PLAY1 = 0;//当前主播放器
|
||||||
private final int MODEL_PLAY2 = 1;//当前子播放器
|
private final int MODEL_PLAY2 = 1;//当前子播放器
|
||||||
private final ExoPlayer player1;
|
private ExoPlayer player1;
|
||||||
private final ExoPlayer player2;
|
private ExoPlayer player2;
|
||||||
private StyledPlayerView mainView;//渲染视图
|
private StyledPlayerView mainView;//渲染视图
|
||||||
private int status = MODEL_PLAY1;
|
private int status = MODEL_PLAY1;
|
||||||
private Player.Listener listener;
|
private Player.Listener listener;
|
||||||
@ -324,14 +326,19 @@ public class LiveExoPlayerManager {
|
|||||||
* 是否正在播放
|
* 是否正在播放
|
||||||
*/
|
*/
|
||||||
public boolean isPlaying() {
|
public boolean isPlaying() {
|
||||||
return getNowPlayer().isPlaying();
|
if (getNowPlayer() != null) {
|
||||||
|
return getNowPlayer().isPlaying();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止播放
|
* 停止播放
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
getNowPlayer().stop();
|
if (getNowPlayer() != null) {
|
||||||
|
getNowPlayer().stop();
|
||||||
|
}
|
||||||
clearUrl();
|
clearUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,8 +351,12 @@ public class LiveExoPlayerManager {
|
|||||||
|
|
||||||
public void replay() {
|
public void replay() {
|
||||||
Log.i(TAG, "replay: 重载播放");
|
Log.i(TAG, "replay: 重载播放");
|
||||||
getNowPlayer().stop();
|
if (getNowPlayer() != null) {
|
||||||
getNextPlayer().stop();
|
getNowPlayer().stop();
|
||||||
|
}
|
||||||
|
if (getNextPlayer() != null) {
|
||||||
|
getNextPlayer().stop();
|
||||||
|
}
|
||||||
String tmp = url;
|
String tmp = url;
|
||||||
url = null;
|
url = null;
|
||||||
startUrl(tmp);
|
startUrl(tmp);
|
||||||
@ -363,8 +374,23 @@ public class LiveExoPlayerManager {
|
|||||||
*/
|
*/
|
||||||
public void release() {
|
public void release() {
|
||||||
Log.i(TAG, "release: 释放播放器");
|
Log.i(TAG, "release: 释放播放器");
|
||||||
player1.release();
|
if (player1 != null) {
|
||||||
player2.release();
|
player1.clearVideoSurface();
|
||||||
|
player1.release();
|
||||||
|
}
|
||||||
|
if (player2 != null) {
|
||||||
|
player2.clearVideoSurface();
|
||||||
|
player2.release();
|
||||||
|
}
|
||||||
|
player1 = null;
|
||||||
|
player2 = null;
|
||||||
|
mainView.setKeepContentOnPlayerReset(false);
|
||||||
|
mainView.setPlayer(null);
|
||||||
|
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainView.getLayoutParams();
|
||||||
|
layoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
mainView.setLayoutParams(layoutParams);
|
||||||
|
mainView.removeAllViews();
|
||||||
|
mainView.requestLayout();
|
||||||
handler.removeCallbacks(buffRunnable);
|
handler.removeCallbacks(buffRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
|
|
||||||
private boolean mPausedPlay;//是否被动暂停了播放
|
private boolean mPausedPlay;//是否被动暂停了播放
|
||||||
public int landscape; //1h 2s
|
public int landscape; //1h 2s
|
||||||
public static Context contexts;
|
public Context contexts;
|
||||||
public static FrameLayout ry_view;
|
public FrameLayout ry_view;
|
||||||
|
|
||||||
private static final int VIDEO_VERTICAL = 2;
|
private static final int VIDEO_VERTICAL = 2;
|
||||||
private static final int VIDEO_HORIZONTAL = 1;
|
private static final int VIDEO_HORIZONTAL = 1;
|
||||||
@ -138,6 +138,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
|
Log.i(TAG, "init: 初始化播放器ViewHolder");
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
Bus.getOn(this);
|
Bus.getOn(this);
|
||||||
mRoot = (ViewGroup) findViewById(R.id.root);
|
mRoot = (ViewGroup) findViewById(R.id.root);
|
||||||
@ -376,6 +377,24 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
public void clearFrame() {
|
public void clearFrame() {
|
||||||
super.clearFrame();
|
super.clearFrame();
|
||||||
mPlayer.clearFrame();
|
mPlayer.clearFrame();
|
||||||
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
|
||||||
|
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
|
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||||
|
params.addRule(RelativeLayout.ALIGN_TOP);
|
||||||
|
mVideoView.setLayoutParams(params);
|
||||||
|
mVideoView.requestLayout();
|
||||||
|
|
||||||
|
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
|
||||||
|
params1.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
|
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
|
||||||
|
params1.addRule(RelativeLayout.ALIGN_TOP);
|
||||||
|
ry_view.setLayoutParams(params1);
|
||||||
|
ry_view.requestLayout();
|
||||||
|
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
|
||||||
|
params2.height = DpUtil.dp2px(270);
|
||||||
|
params2.topMargin = DpUtil.dp2px(120);
|
||||||
|
mCover.setLayoutParams(params2);
|
||||||
|
mCover.requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -314,6 +314,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600);
|
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600);
|
||||||
|
|
||||||
mask.setVisibility(View.VISIBLE);
|
mask.setVisibility(View.VISIBLE);
|
||||||
|
mLivePlayViewHolder.clearFrame();
|
||||||
mLivePlayViewHolder.setLiveBean(mLiveBean);
|
mLivePlayViewHolder.setLiveBean(mLiveBean);
|
||||||
mLivePlayViewHolder.setCover(mLiveBean.getAvatar());
|
mLivePlayViewHolder.setCover(mLiveBean.getAvatar());
|
||||||
mLivePlayViewHolder.setLiveBeanLandscape(mLiveBean.getLandscape());
|
mLivePlayViewHolder.setLiveBeanLandscape(mLiveBean.getLandscape());
|
||||||
|
Loading…
Reference in New Issue
Block a user