手机开播场景(页面)
1 Feature Overview
The page implementation for the mobile streaming scenario is PLVLSStreamerViewController.
The mobile streaming scenario supports features such as streaming, co-hosting, chat, PPT & whiteboard, and document management.
2 Usage Guide
Since the initialization parameters required for the mobile streaming page, such as channel information and user account details, are configured via the class PLVRoomLoginClient during login, and the live room data is managed internally by PLVRoomLoginClient using the singleton of the PLVRoomDataManager class, entering the mobile streaming page only requires the following code:
PLVLSStreamerViewController *vctrl = [[PLVLSStreamerViewController alloc] init];
vctrl.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vctrl animated:YES completion:nil];
When leaving the mobile streaming page, in addition to removing the page from the page stack, be sure to call the logout interface of PLVRoomLoginClient to remove the PLVRoomDataManager singleton's retention and monitoring of the current live room data:
[PLVRoomLoginClient logout];
[self dismissViewControllerAnimated:YES completion:nil];
3 Page Introduction
3.1 Page UI
The layout of the mobile streaming page consists of the following page UI controls:
@property (nonatomic, strong) PLVLSStatusAreaView *statusAreaView; // 顶部状态栏区域
@property (nonatomic, strong) UIView *streamerAreaView; // 右侧推流&连麦区域
@property (nonatomic, strong) PLVLSDocumentAreaView *documentAreaView; // 左侧白板&PPT区域
@property (nonatomic, strong) PLVLSChatroomAreaView *chatroomAreaView; // 左下角聊天室区域
Additionally, the mobile streaming page includes the following (non-persistent) UI controls:
@property (nonatomic, strong) PLVLSChannelInfoSheet *channelInfoSheet; // 频道信息弹层
@property (nonatomic, strong) PLVLSSettingSheet *settingSheet; // 设置弹层
@property (nonatomic, strong) PLVLSMemberSheet *memberSheet; // 成员管理弹层
@property (nonatomic, strong) PLVLSCountDownView *coutBackView; // 开始上课时的倒数蒙层
Finally, the mobile streaming page does not support portrait mode, only landscape mode. Therefore, the following methods of the parent class UIViewController need to be overridden:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
3.2 Live Room Data Monitoring
The page needs to monitor the live room data PLVRoomData in real time and update the UI accordingly. First, import the header file #import "PLVRoomDataManager.h", and make PLVLSStreamerViewController conform to the protocol PLVRoomDataManagerProtocol. Then, add the monitoring. The code example is as follows:
[[PLVRoomDataManager sharedManager] addDelegate:self delegateQueue:dispatch_get_main_queue()];
In the code example, passing delegateQueue as the parameter dispatch_get_main_queue() indicates that the callback method should be executed on the main thread, as all operations in the relevant callbacks of the current page involve UI updates.
For more information about PLVRoomDataManager, refer to the document "6_2 Core Common-Data".
The delegate methods that the mobile streaming page needs to monitor are as follows:
#pragma mark - PLVRoomDataManager Protocol
/// 菜单信息 menuInfo 更新
- (void)roomDataManager_didMenuInfoChanged:(PLVLiveVideoChannelMenuInfo *)menuInfo {
// 此时更新频道信息弹层数据不能使用self,会过早触发弹层初始化,导致弹层高度计算错误
[_channelInfoSheet updateChannelInfoWithData:menuInfo];
}
The removal of monitoring is handled internally within the logout method +logout of PLVRoomLoginClient, as mentioned in 2 Usage Guide, so no additional monitoring removal operations are required.
