调整进直播间loading界面与播放器绑定,播放器准备完成后再隐藏。

优化播放器加载速度1
This commit is contained in:
zlzw 2023-01-08 15:50:40 +08:00
parent 9fcc04cef2
commit 27bd65d3da
4 changed files with 34 additions and 6 deletions

View File

@ -106,7 +106,7 @@ public class LiveExoPlayerManager {
Log.i(TAG, "onPlaybackStateChanged 1: " + playbackState);
if (playbackState == Player.STATE_READY) {
player2.stop();
player2.setVideoSurface(null);
player2.clearVideoSurface();
player1.play();
Log.i(TAG, "切换播放器1");
handler.removeCallbacks(buffRunnable);
@ -159,7 +159,7 @@ public class LiveExoPlayerManager {
Log.i(TAG, "onPlaybackStateChanged 2: " + playbackState);
if (playbackState == Player.STATE_READY) {
player1.stop();
player1.setVideoSurface(null);
player1.clearVideoSurface();
player2.play();
Log.i(TAG, "切换播放器2 " + player2.isPlaying());
handler.removeCallbacks(buffRunnable);

View File

@ -196,7 +196,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.i(TAG, "setLiveBeanLandscape: " + landscape);
this.landscape = landscape;
this.videoLandscape = landscape;
mPlayer.setViewResizeMode(landscape==VIDEO_VERTICAL);
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
if (landscape == 2) {
Log.i("收到socket--->", "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
@ -1031,6 +1031,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
});
}
@Override
public void setLoadViewListener(LoadingListener listener) {
super.setLoadViewListener(listener);
}
private void showLoadingDialog() {
if (PLAY_MODEL == PLAY_MODEL_480) return;
@ -1081,6 +1086,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (playbackState == Player.STATE_BUFFERING) {
//showLoadingDialog();
OkDownload.getInstance().pauseAll();
Log.i(TAG, "onPlaybackStateChanged: 缓存中");
}else{
Log.i(TAG, "onPlaybackStateChanged: 播放中");
}
}
@ -1089,7 +1097,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Player.Listener.super.onIsPlayingChanged(isPlaying);
if (isPlaying) {
hideCover();
Log.i(TAG, "onIsPlayingChanged: 开始播放");
OkDownload.getInstance().startAll();
if (loadingListener != null) {
loadingListener.onPlayer();
}
}
}
}

View File

@ -25,6 +25,7 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public static final String[] videoFps = new String[]{"_24", "_30"};
OnMicCallback onMicCallback;//连麦回调
public EnterRoomNewModel roomModel;
LoadingListener loadingListener;
public LiveRoomPlayViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@ -62,7 +63,8 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
this.mLiveBean = data;
}
public void setViewUP(int i){}
public void setViewUP(int i) {
}
public OnMicCallback getOnMicCallback() {
return onMicCallback;
@ -76,9 +78,17 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
this.roomModel = data;
}
public void setLoadViewListener(LoadingListener listener) {
this.loadingListener = listener;
}
public interface OnMicCallback {
void onMikUpdate();
}
public interface LoadingListener {
void onPlayer();
}
}

View File

@ -276,6 +276,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
mLivePlayViewHolder.addToParent();
mLivePlayViewHolder.subscribeActivityLifeCycle();
mLivePlayViewHolder.setLoadViewListener(new LiveRoomPlayViewHolder.LoadingListener() {
@Override
public void onPlayer() {
loading.setVisibility(View.GONE);
}
});
mLiveRoomViewHolder.subscribeActivityLifeCycle();
mLiveAudienceViewHolder.addToParent();
mLiveRoomViewHolder.addToParent();
@ -358,7 +364,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
landscape = data.getLiveInfo().getLandscape();
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
mLivePlayViewHolder.setLiveEnterRoomNewModel(data);
mLivePlayViewHolder.switchStream(mLiveBean.getPull(), (data.getClarityType() - 1) == 2 ? 1 : (data.getClarityType() - 1));
//mLivePlayViewHolder.switchStream(mLiveBean.getPull(), (data.getClarityType() - 1) == 2 ? 1 : (data.getClarityType() - 1));
//是否热度卡加成
liveHandler.postDelayed(() -> mLiveRoomViewHolder.getIsHot(data.getIsUseHotCard()), 700);
@ -580,7 +586,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
}
}
liveHandler.postDelayed(() -> loading.setVisibility(View.GONE), 700);
//liveHandler.postDelayed(() -> loading.setVisibility(View.GONE), 700);
}