/**
* 启动手机开播页
*
* @param activity 上下文Activity
* @param channelId 频道号
* @param viewerId 开播者ID
* @param viewerName 开播者昵称
* @param avatarUrl 开播者头像url
* @param actor 开播者头衔
* @param isOpenMic 是否打开麦克风
* @param isOpenCamera 是否打开相机
* @param isFrontCamera 是否使用前置摄像头
* @return PLVLaunchResult.isSuccess=true表示启动成功,PLVLaunchResult.isSuccess=false表示启动失败
*/
public static PLVLaunchResult launchStreamer(@NonNull Activity activity,
@NonNull String channelId,
@NonNull String viewerId,
@NonNull String viewerName,
@NonNull String avatarUrl,
@NonNull String actor,
boolean isOpenMic,
boolean isOpenCamera,
boolean isFrontCamera);
private void initParams() {
// 获取输入数据
Intent intent = getIntent();
String channelId = intent.getStringExtra(EXTRA_CHANNEL_ID);
String viewerId = intent.getStringExtra(EXTRA_VIEWER_ID);
String viewerName = intent.getStringExtra(EXTRA_VIEWER_NAME);
String avatarUrl = intent.getStringExtra(EXTRA_AVATAR_URL);
String actor = intent.getStringExtra(EXTRA_ACTOR);
// 设置Config数据
PLVLiveChannelConfigFiller.setupUser(viewerId, viewerName, avatarUrl, PLVSocketUserConstant.USERTYPE_TEACHER, actor);
PLVLiveChannelConfigFiller.setupChannelId(channelId);
}
private void initLiveRoomManager() {
// 使用PLVLiveChannelConfigFiller配置好直播参数后,用其创建直播间数据管理器实例
liveRoomDataManager = new PLVLiveRoomDataManager(PLVLiveChannelConfigFiller.generateNewChannelConfig());
// 进行网络请求,获取直播详情数据
liveRoomDataManager.requestChannelDetail();
}
private void initView() {
// 初始化推流和连麦布局
plvlsStreamerLy.init(liveRoomDataManager);
// 初始化推流的媒体配置
boolean isOpenMic = getIntent().getBooleanExtra(EXTRA_IS_OPEN_MIC, true);
boolean isOpenCamera = getIntent().getBooleanExtra(EXTRA_IS_OPEN_CAMERA, true);
boolean isFrontCamera = getIntent().getBooleanExtra(EXTRA_IS_FRONT_CAMERA, true);
plvlsStreamerLy.enableRecordingAudioVolume(isOpenMic);
plvlsStreamerLy.enableLocalVideo(isOpenCamera);
plvlsStreamerLy.setCameraDirection(isFrontCamera);
// 初始化状态栏布局
plvlsStatusBarLy.init(liveRoomDataManager);
// 注册成员列表中的streamerView,并请求成员列表接口
plvlsStreamerLy.getStreamerPresenter().registerView(plvlsStatusBarLy.getMemberLayoutStreamerView());
plvlsStreamerLy.getStreamerPresenter().requestMemberList();
// 初始化聊天室布局
plvlsChatroomLy.init(liveRoomDataManager);
// 初始化文档布局
plvlsDocumentLy.init(liveRoomDataManager);
// 进入横屏模式
PLVScreenUtils.enterLandscape(this);
}