3_1-云课堂场景(Activity)
1 Feature Overview
The interface implementation for the cloud classroom scenario is PLVLCCloudClassActivity.
This is the shared interface for both live and replay modes in the cloud classroom scenario. Features supported in live mode include: player, page menu, floating PPT, live mic connection, and interactive applications. Features supported in replay mode include: player, page menu, and floating PPT.
2 Interface Introduction
//1.3.0增加viewerAvatar参数
/**
* 启动直播页
*
* @param activity 上下文Activity
* @param channelId 频道号
* @param viewerId 观众ID
* @param viewerName 观众昵称
* @param viewerAvatar 观众头像
* @return true表示启动成功,false表示启动失败
*/
public static boolean launchLive(@NonNull Activity activity,
@NonNull String channelId,
@NonNull String viewerId,
@NonNull String viewerName,
@NonNull String viewerAvatar);
/**
* 启动回放页面
*
* @param activity 上下文Activity
* @param channelId 频道号
* @param vid 视频ID
* @param viewerId 观众ID
* @param viewerName 观众昵称
* @param viewerAvatar 观众头像
* @param videoListType 回放视频类型,参考{@link PolyvPlaybackListType}
* @return true表示启动成功,false表示启动失败
*/
public static boolean launchPlayback(@NonNull Activity activity,
@NonNull String channelId,
@NonNull String vid,
@NonNull String viewerId,
@NonNull String viewerName,
@NonNull String viewerAvatar,
int videoListType);
3 Implementation Introduction
The cloud classroom encapsulates each functional module into a Layout class. Integration can be achieved by simply combining layouts in the Activity.
3.1 Initialize Page Parameters
private void initParams() {
// 获取输入数据
Intent intent = getIntent();
boolean isLive = intent.getBooleanExtra(EXTRA_IS_LIVE, true);
String channelId = intent.getStringExtra(EXTRA_CHANNEL_ID);
String viewerId = intent.getStringExtra(EXTRA_VIEWER_ID);
String viewerName = intent.getStringExtra(EXTRA_VIEWER_NAME);
// 设置Config数据
PLVLiveChannelConfigFiller.setIsLive(isLive);
PLVLiveChannelConfigFiller.setupUser(viewerId, viewerName);
PLVLiveChannelConfigFiller.setupChannelId(channelId);
// 根据不同模式,设置对应参数
if (!isLive) { // 回放模式
String vid = intent.getStringExtra(EXTRA_VID);
int videoListType = intent.getIntExtra(EXTRA_VIDEO_LIST_TYPE, PolyvPlaybackListType.PLAYBACK);
PLVLiveChannelConfigFiller.setupVid(vid);
PLVLiveChannelConfigFiller.setupVideoListType(videoListType);
}
}
3.2 Initialize Live Room Data Manager
private void initLiveRoomManager() {
// 使用PLVLiveChannelConfigFiller配置好直播参数后,用其创建直播间数据管理器实例
liveRoomDataManager = new PLVLiveRoomDataManager(PLVLiveChannelConfigFiller.generateNewChannelConfig());
// 进行网络请求,获取上报观看热度
liveRoomDataManager.requestPageViewer();
// 进行网络请求,获取直播详情数据
liveRoomDataManager.requestChannelDetail();
// 进行网络请求,获取功能开关数据
liveRoomDataManager.requestChannelSwitch();
}
3.3 Initialize Page UI
private void initView() {
//初始化共用的UI
if(liveRoomDataManager.getConfig().isLive()){
//初始化直播的UI
}else{
//初始化回放的UI
}
}
Depending on whether it is live or replay, different combinations of Layout controls are selected for initialization.
Features supported in live mode include: player, page menu, floating PPT, live mic connection, and interactive applications. Features supported in replay mode include: player, page menu, and floating PPT.
The layout interfaces for each functional module are as follows:
Player layout interface: IPLVLCMediaLayout Live mic connection layout interface: IPLVLCLinkMicLayout Live page menu layout interface: IPLVLCLivePageMenuLayout Interactive application layout interface: IPLVInteractLayout PPT layout interface: IPLVLCFloatingPPTLayout
3.4 Set Layout Callbacks
Since communication is required between various functions—for example, the player's live start and end states affect the display and hiding of the PPT—each layout provides external callbacks to facilitate communication between functional modules.
For detailed interface introductions, please refer to the specific articles for each functional module.
For callback setup and handling, please refer to the Set Layout Callbacks method block in the Activity.
3.5 Handle Screen Rotation
Both live and replay modes in the cloud classroom scenario support landscape and portrait viewing. Corresponding code handling is required in the Activity.
Refer to the code block: Screen Rotation Handling
