7_2-核心common-配置
更新時間:2023-04-17 15:27:57
1 概述
配置模組位於polyvLiveCommonModul模組的config包下,包含多場景 SDK 的初始化配置類、直播頻道相關資訊的配置類。
2 核心類別介紹
2.1 PLVLiveSDKConfig
多場景 SDK 初始化的配置類,需先使用此類別初始化 SDK 後,才能正常使用 SDK 的功能。使用範例:
public class PLVApp extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
//初始化sdk
PLVLiveSDKConfig.init(
new PLVLiveSDKConfig.Parameter(this)
.isOpenDebugLog(true)
.isEnableHttpDns(false)
);
}
}
2.2 PLVLiveChannelConfigFiller
直播頻道相關資料的填充器,在進入直播/回放場景頁時,需提供直播帳號的appId(應用程式 ID)、appSecret(應用程式密鑰)、userId(帳號 ID)、channelId(頻道號碼)、vid(影片 ID)等參數。使用此類別配置好這些參數後,其他功能模組即可透過此類別呼叫generateNewChannelConfig方法產生的PLVLiveChannelConfig存取上述配置資訊。使用範例:
PLVLoginActivity
private void loginLive() {
//...
//填充账号信息
PLVLiveChannelConfigFiller.setupAccount(userId, appId, appSecret);
//...
}
PLVLCCloudClassActivity
private void initParams() {
//...
//填充播放类型、用户、频道等信息
PLVLiveChannelConfigFiller.setIsLive(isLive);
PLVLiveChannelConfigFiller.setupUser(viewerId, viewerName);
PLVLiveChannelConfigFiller.setupChannelId(channelId);
//...
}
private void initLiveRoomManager() {
//...
// 使用PLVLiveChannelConfigFiller配置好直播参数后,用其创建直播间数据管理器实例,以供其他模块访问
liveRoomDataManager = new PLVLiveRoomDataManager(PLVLiveChannelConfigFiller.generateNewChannelConfig());
//...
}
