Polyv Help Center

Help Center

核心common 配置

Updated: 2023-04-17 15:27:57

1 Overview

The configuration module is located under the polyvLiveCommonModul package of the config module. It includes the initialization configuration class for the multi-scene SDK and the configuration class for live channel-related information.

2 Core Class Introduction

2.1 PLVLiveSDKConfig

This is the configuration class for initializing the multi-scene SDK. The SDK must be initialized using this class before its features can be used normally. Usage example:

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

This is a filler for live channel-related data. When entering a live broadcast or playback scene page, parameters such as the live account's appId (App ID), appSecret (App Secret), userId (Account ID), channelId (Channel Number), and vid (Video ID) need to be provided. After configuring these parameters using this class, other functional modules can access the above configuration information by calling the generateNewChannelConfig method to generate the PLVLiveChannelConfig. Usage example:

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());
    //...
}
联系客服,在线咨询
在线咨询