主播准备页

最近更新时间:2025-08-29 15:29:01

我的收藏

功能简介

主播准备页主要是指主播在开始直播之前,实现摄像头预览、调整美颜参数、设置摄像头翻转的页面。本文将介绍如何在 10 分钟之内完成主播准备页的接入工作。


布局介绍

您可以单击布局进行布局设置。

各布局效果示例如下:
动态宫格布局
浮动小窗布局
静态宫格布局
固定小窗布局





前提条件

在完成该功能接入之前,需要先完成概述中的 接入步骤

功能接入

1. 创建主播准备页视图并初始化。
Kotlin
Java
val roomId = "1236666"

val anchorPrepareView = AnchorPrepareView(context)
anchorPrepareView.init(roomId, null)
String roomId = "live_123456";

mAnchorPrepareView = new AnchorPrepareView(this);
mAnchorPrepareView.init(roomId, null);
2. 将主播准备页加载到 Activity 中。
Kotlin
Java
setContentView(mAnchorPrepareView)
setContentView(mAnchorPrepareView);
3. 获取主播准备页提供的视图数据。
主播准备页可以设置封面、设置直播间名称、设置直播模式,您可以通过 getState(),获取您设置具体的值。
Kotlin
Java
val state: PrepareState = anchorPrepareView.getState()
val roomName = state.roomName.getValue()
val coverURL = state.coverURL.getValue()
val liveMode: LiveStreamPrivacyStatus? = state.liveMode.getValue()
PrepareState state = mAnchorPrepareView.getState();
String roomName = state.roomName.getValue();
String coverURL = state.coverURL.getValue();
LiveStreamPrivacyStatus liveMode = state.liveMode.getValue();
4. 添加开始直播按钮点击事件。
Kotlin
Java
// 在您的 Activity 中实现 AnchorPrepareViewDefine.AnchorPrepareViewListener 接口,并重写下面两个方法。
// 点击开始直播按钮回调
override fun onClickStartButton() {
//
}

override fun onClickBackButton() {
finish();
}

// 给主播准备页视图添加监听器。
anchorPrepareView.addAnchorPrepareViewListener(this)
// 在您的 Activity 中实现 AnchorPrepareViewDefine.AnchorPrepareViewListener 接口,并重写下面两个方法。
// 点击开始直播按钮回调
@Override
public void onClickStartButton() {

}

// 点击返回按钮回调
@Override
public void onClickBackButton() {
}

// 给主播准备页视图添加监听器。
mAnchorPrepareView.addAnchorPrepareViewListener(this);

功能定制

隐藏操作区视图

Kotlin
Java
anchorPrepareView.disableFeatureMenu(true)
mAnchorPrepareView.disableFeatureMenu(true);

隐藏操作区美颜功能

Kotlin
Java
anchorPrepareView.disableMenuBeautyButton(true)
mAnchorPrepareView.disableMenuBeautyButton(true);

隐藏操作区音效功能

Kotlin
Java
anchorPrepareView.disableMenuAudioEffectButton(true)
mAnchorPrepareView.disableMenuAudioEffectButton(true);

隐藏操作区翻转功能

Kotlin
Java
anchorPrepareView.disableMenuSwitchButton(true)
mAnchorPrepareView.disableMenuSwitchButton(true);