fix[声望升级-秒开]

This commit is contained in:
Martin
2024-06-01 11:16:26 +08:00
parent ce9336737f
commit 19c270ad22
7 changed files with 63 additions and 26 deletions

View File

@@ -98,16 +98,18 @@ public class SWAuManager extends BaseCacheManager {
*/
public void initRtcEngine(Activity mContext) {
this.mContext = mContext;
try {
// 创建 RtcEngineConfig 对象,并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
if(mRtcEngine==null){
try {
// 创建 RtcEngineConfig 对象,并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}
}
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式,引擎級別
// 开启本地预览
@@ -120,13 +122,15 @@ public class SWAuManager extends BaseCacheManager {
public void initRtcEngineAudio(Activity mContext) {
this.mContext = mContext;
try {
if(mRtcEngine==null){
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
}
// 创建 RtcEngineConfig 对象,并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
mRtcEngine.enableAudio();
mRtcEngine.enableLocalAudio(true);
} catch (Exception e) {
@@ -417,7 +421,9 @@ public class SWAuManager extends BaseCacheManager {
}
public void preloadChannel(List<LiveBean> uids){
L.eSw("设置秒开数据");
for (int i = 0; i <uids.size(); i++) {
L.eSw("设置秒开数据 uid"+uids.get(i).getUid()+" --- userName:"+uids.get(i).getUserNiceName());
mRtcEngine.preloadChannel(CommonAppConfig.SWToken,getChannelName(uids.get(i).getUid()),Integer.parseInt(CommonAppConfig.getInstance().getUid()));
}
}

View File

@@ -91,13 +91,16 @@ public class SWManager extends BaseCacheManager {
uid = Integer.parseInt(strUid);
}
try {
// 创建 RtcEngineConfig 对象,并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
if(mRtcEngine==null){
// 创建 RtcEngineConfig 对象,并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
}
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}