延迟大法解决屏幕分享黑屏的问题

This commit is contained in:
zher52 2022-02-22 23:25:43 +08:00
parent 05f1650517
commit 7c32c6a709

View File

@ -2,6 +2,7 @@ package com.tencent.trtc;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -84,8 +85,14 @@ public class CustomVideoView extends RelativeLayout {
mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_SPEECH); mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_SPEECH);
mTRTCCloud.setLocalRenderParams(params); mTRTCCloud.setLocalRenderParams(params);
} else { } else {
mTRTCCloud.startRemoteView(this.userInfo.getPersonid(), mainView ? TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG : TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SMALL, videoView);
mTRTCCloud.setRemoteRenderParams(this.userInfo.getPersonid(),mainView ? TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG : TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB,params); mTRTCCloud.setRemoteRenderParams(this.userInfo.getPersonid(),mainView ? TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG : TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB,params);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
mTRTCCloud.startRemoteView(this.userInfo.getPersonid(), mainView ? TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG : TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SMALL, videoView);
} }
if(this.userInfo.getDisplayName() == null || this.userInfo.getDisplayName().length() == 0){ if(this.userInfo.getDisplayName() == null || this.userInfo.getDisplayName().length() == 0){
this.titleView.setText(this.userInfo.getPersonid() + (this.userInfo.isShareUser() ? "的屏幕分享": "")); this.titleView.setText(this.userInfo.getPersonid() + (this.userInfo.isShareUser() ? "的屏幕分享": ""));
@ -103,8 +110,10 @@ public class CustomVideoView extends RelativeLayout {
} }
} }
} }
Log.d(TAG,"TRTC - changeUser >>>>"+(userInfo == null ? null : userInfo.getPersonid())+"|"+ ((ColorDrawable)getBackground()).getColor());
} }
private boolean isChanged(UserInfo userInfo){ private boolean isChanged(UserInfo userInfo){
return (this.userInfo == null && userInfo !=null) || return (this.userInfo == null && userInfo !=null) ||
(this.userInfo != null && !this.userInfo.equals(userInfo)); (this.userInfo != null && !this.userInfo.equals(userInfo));