fix[声望升级-APPID 更换存储位置]

This commit is contained in:
Martin 2024-06-01 10:32:32 +08:00
parent 11c9a53028
commit 39cf76439f
3 changed files with 14 additions and 9 deletions

View File

@ -79,6 +79,8 @@ public class CommonAppConfig {
public static String SWToken = ""; //声网Token public static String SWToken = ""; //声网Token
public static final String SWChannelPrefix = "g"; public static final String SWChannelPrefix = "g";
public static final String SWAPPId = "4cf0376582d742ac8a96778b25b1079e";
/** /**
* 获取通道 * 获取通道

View File

@ -10,6 +10,7 @@ import android.widget.FrameLayout;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.API; import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.ResponseModel;
@ -21,6 +22,8 @@ import com.yunbao.common.utils.L;
import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import java.util.List;
import io.agora.rtc2.ChannelMediaOptions; import io.agora.rtc2.ChannelMediaOptions;
import io.agora.rtc2.Constants; import io.agora.rtc2.Constants;
import io.agora.rtc2.IRtcEngineEventHandler; import io.agora.rtc2.IRtcEngineEventHandler;
@ -43,9 +46,6 @@ import io.rong.message.TextMessage;
*/ */
public class SWAuManager extends BaseCacheManager { public class SWAuManager extends BaseCacheManager {
// 填写项目的 App ID可在声网控制台中生成
public static final String shengwang_appId = "4cf0376582d742ac8a96778b25b1079e";
// 填写频道名
private Activity mContext; private Activity mContext;
public static SWAuManager manager; public static SWAuManager manager;
private RtcEngineEx mRtcEngine; private RtcEngineEx mRtcEngine;
@ -102,7 +102,7 @@ public class SWAuManager extends BaseCacheManager {
// 创建 RtcEngineConfig 对象并进行配置 // 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig(); RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext; config.mContext = mContext;
config.mAppId = SWAuManager.shengwang_appId; config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler; config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine // 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config); mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
@ -123,7 +123,7 @@ public class SWAuManager extends BaseCacheManager {
// 创建 RtcEngineConfig 对象并进行配置 // 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig(); RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext; config.mContext = mContext;
config.mAppId = SWAuManager.shengwang_appId; config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mEventHandler; config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine // 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config); mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
@ -415,4 +415,10 @@ public class SWAuManager extends BaseCacheManager {
public interface SwListener { public interface SwListener {
void onUserOffline(int liveUid); void onUserOffline(int liveUid);
} }
public void preloadChannel(List<LiveBean> uids){
for (int i = 0; i <uids.size(); i++) {
mRtcEngine.preloadChannel(CommonAppConfig.SWToken,getChannelName(uids.get(i).getUid()),Integer.parseInt(CommonAppConfig.getInstance().getUid()));
}
}
} }

View File

@ -42,9 +42,6 @@ import io.agora.rtc2.video.VideoEncoderConfiguration;
*/ */
public class SWManager extends BaseCacheManager { public class SWManager extends BaseCacheManager {
// 填写项目的 App ID可在声网控制台中生成
public static final String shengwang_appId = "4cf0376582d742ac8a96778b25b1079e";
// 填写频道名
private Activity mContext; private Activity mContext;
public static SWManager manager; public static SWManager manager;
private RtcEngineEx mRtcEngine; private RtcEngineEx mRtcEngine;
@ -97,7 +94,7 @@ public class SWManager extends BaseCacheManager {
// 创建 RtcEngineConfig 对象并进行配置 // 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig(); RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext; config.mContext = mContext;
config.mAppId = SWManager.shengwang_appId; config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler; config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine // 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config); mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);