| 属性 | 属性描述 |
|---|---|
| delegate | 代理对象 |
| moviePlayerView | 获取播放器view |
| documentView | 获取文档演示view,如果没有文档则为nil (在收到"文档显示/隐藏回调"后获取) |
| realityBufferTime | 获取RTMP播放实际的缓冲时间,单位毫秒 |
| activeState | 活动状态 (在收到"视频信息预加载回调"或"播放连接成功回调"后使用) |
| playerState | 获取播放器状态 |
| webinarInfo | 活动详情 |
| timeout | 设置链接的超时时间 默认5000毫秒,单位为毫秒 MP4点播 最小10000毫秒 |
| bufferTime | 设置RTMP 的缓冲时间 默认 6秒 单位为秒 必须>0 值越小延时越小,卡顿增加 |
| movieScalingMode | 设置视频的填充模式 默认是自适应模式:VHRTMPMovieScalingModeAspectFit |
| defaultDefinition | 设置默认播放的清晰度 默认原画 |
| curDefinition | 设置当前播放的清晰度 |
| 方法 | 方法描述 |
|---|---|
| initWithDelegate | 初始化 |
| preLoadRoomWithParam | 预加载房间信息 |
| startPlay | 开始播放 |
| startPlay:isPIP: | 开始播放并配置画中画 |
| pausePlay | 暂停播放 |
| reconnectPlay | 恢复播放 |
| stopPlay | 停止播放 |
| setMute | 设置静音 |
| destroyMoivePlayer | 销毁播放器 |
| 方法 | 方法描述 |
|---|---|
| microApplyWithType | 申请上麦/取消申请 |
| replyInvitationWithType | 是否同意上麦 |
| 方法 | 方法描述 |
|---|---|
| cleanLastFrame | 清空视频剩余的最后一帧画面 |
| dlnaMappingObject | 设置投屏对象 |
| reconnectSocket | 重连socket |
| playerBackgroundColor | playerBackgroundColor |
| playerBackgroundImage | 设置播放器背景图片 |
| audioOutput | 设置音频输出设备 |
| openPIPSupported | 开启画中画 |
| closePIPSupported | 关闭画中画 |
| setIsOpenPIP | 是否开启画中画 |
| 方法 | 方法描述 |
|---|---|
| preLoadVideoFinish | 视频信息预加载完成回调 |
| connectSucceed | 播放连接成功回调 |
| liveDidStart | 直播开始消息 |
| liveDidStoped | 直播结束消息 |
| bufferStart | 缓冲开始回调 |
| bufferStop | 缓冲结束回调 |
| downloadSpeed | 下载速率的回调 |
| recStreamtype | 视频流类型回调 |
| playError | 播放时错误的回调 |
| activeStateDidChange | 当前活动状态回调 |
| loadVideoPlayMode | 当前视频播放模式,以及是否为vr活动回调 |
| loadVideoPlayModeList | 当前视频支持的播放模式列表回调 |
| loadVideoDefinitionList | 当前视频支持的清晰度列表回调 |
| statusDidChange | 播放器状态回调 |
| videoSize | 视频宽髙回调(支持直播与点播) |
| isInteractiveActivity | 当前活动是否允许举手申 请上麦回调 |
| microInvitationWithAttributes | 主持人是否同意上麦申请回调 |
| microInvitation | 被主持人邀请上麦 |
| isKickout | 被踢出 |
| isCast_screen | 当前是否支持投屏功能 |
| isHaveDocument | 主持人显示/隐藏文档 |
| documentDelayTime | 直播文档同步,直播文档有延迟,指定需要延迟的秒数 |
| announcementContentDidChange | 发布公告的回调 |
| isQuestion_status | 当前是否开启问答功能 |
| is_file_download | 当前是否开启文件下载功能 |
| pictureInPictureControllerWillStart | 即将开启画中画 |
| pictureInPictureControllerDidStart | 已经开启画中画 |
| pictureInPictureWithFailedToStartPictureInPictureWithError | 开启画中画失败 |
| pictureInPictureControllerWillStop | 即将关闭画中画 |
| pictureInPictureControllerDidStop | 已经关闭画中画 |
| pictureInPictureWithRestoreUserInterfaceForPictureInPictureStopWithCompletionHandler | 关闭画中画且恢复播放界面 |
初始化VHMoviePlayer对象
- (instancetype)initWithDelegate:(id <VHallMoviePlayerDelegate>)delegate;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| delegate | 是 | self | 代理对象 |
| 参数名称 | 备注 |
|---|---|
| VHMoviePlayer | 观看直播对象 |
@interface UIViewController ()<VHallMoviePlayerDelegate>
// 播放器
@property (nonatomic, strong) VHallMoviePlayer *moviePlayer;
@end
- (void)viewDidLoad {
[super viewDidLoad];
/// 初始化
self.moviePlayer = [[VHallMoviePlayer alloc]initWithDelegate:self];
}在收到"视频信息预加载完成回调"后,即可使用聊天、签到、问答、抽奖等功能,然后择机调用startPlay/startPlayback进行播放,注意使用此方法后,startPlay和startPlayback传参将不再生效(此方法主要用于播放之前需要使用聊天等功能)
- (void)preLoadRoomWithParam:(NSDictionary *)param;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| param | 是 | 字典 | 活动基础信息,包含以下参数 |
| param[@"id"] | 是 | 123456789 | 活动Id,必传 |
| param[@"name"] | 否 | 阿超 | 昵称 |
| param[@"auth_model"] | 否 | 1 | 0 : 校验观看权限(默认) 1 : 不校验观看权限 |
NSMutableDictionary * param = [[NSMutableDictionary alloc] init];
param[@"id"] = @"123456789";
param[@"name"] = @"阿超";
param[@"auth_model"] = @(1);
[self.moviePlayer preLoadRoomWithParam:param];在收到"播放连接成功回调"后,才可使用聊天、签到、问答、抽奖等功能
- (BOOL)startPlay:(NSDictionary *)param;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| param | 是 | 字典 | 活动基础信息,包含以下参数 |
| param[@"id"] | 是 | 123456789 | 活动Id,必传 |
| param[@"name"] | 否 | 阿超 | 昵称 |
| param[@"auth_model"] | 否 | 1 | 0 : 校验观看权限(默认) 1 : 不校验观看权限 |
NSMutableDictionary * param = [[NSMutableDictionary alloc] init];
param[@"id"] = @"123456789";
param[@"name"] = @"阿超";
param[@"auth_model"] = @(1);
[self.moviePlayer startPlay:param];
在收到"播放连接成功回调"后,才可使用聊天、签到、问答、抽奖等功能
- (BOOL)startPlay:(NSDictionary *)param isPIP:(BOOL)isPIP;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| param | 是 | 字典 | 活动基础信息,包含以下参数 |
| param[@"id"] | 是 | 123456789 | 活动Id,必传 |
| param[@"name"] | 否 | 阿超 | 昵称 |
| param[@"auth_model"] | 否 | 1 | 0 : 校验观看权限(默认) 1 : 不校验观看权限 |
| isPIP | 是 | BOOL | 是否开启画中画 |
NSMutableDictionary * param = [[NSMutableDictionary alloc] init];
param[@"id"] = @"123456789";
param[@"name"] = @"阿超";
param[@"auth_model"] = @(1);
[self.moviePlayer startPlay:param isPIP:YES];直播等同于stopPlay,停止播放
- (void)pausePlay;[self.moviePlayer pausePlay];播放出错/暂停播放后恢复播放
- (BOOL)reconnectPlay;[self.moviePlayer reconnectPlay];- (BOOL)stopPlay;[self.moviePlayer stopPlay];- (void)setMute:(BOOL)mute;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| mute | 是 | YES | 是否静音 |
[self.moviePlayer setMute:YES];- (void)destroyMoivePlayer;[self.moviePlayer destroyMoivePlayer];- (BOOL)microApplyWithType:(NSInteger)type finish:(void(^)(NSError *error))finishBlock;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| type | 是 | 1 | 1申请上麦,0取消申请上麦 |
| finishBlock | 是 | 回调 | 消息发送结果,error为失败详情 |
[self.moviePlayer microApplyWithType:1 finish:^(NSError *error) {
if(error){
NSLog(@"%@",error.description);
}else{
NSLog(@"申请上麦成功");
}
}];- (BOOL)replyInvitationWithType:(NSInteger)type finish:(void(^)(NSError *error))finishBlock;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| type | 是 | 1 | 1接受,2拒绝,3超时失败 |
| finishBlock | 是 | 回调 | 消息发送结果,error为失败详情 |
[self.moviePlayer replyInvitationWithType:1 finish:^(NSError *error) {
if(error){
NSLog(@"%@",error.description);
}else{
NSLog(@"申请上麦成功");
}
}];清空视频剩余的最后一帧画面
- (void)cleanLastFrame;[self.moviePlayer cleanLastFrame]投屏功能使用步骤:1、设置DLNAobj 2、收到DLNAobj设备列表回调后,设置投屏设备 3、DLNAobj初始化播放。如果播放过程中多个player使用对同一个DLNAobj,则DLNAobj需要重新初始化播放
- (BOOL)dlnaMappingObject:(VHDLNAControl *)DLNAobj;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| DLNAobj | 是 | DLNAobj | 投屏对象 |
| 参数名称 | 备注 |
|---|---|
| return BOOL | YES 可投屏,NO不可投屏 |
[self.moviePlayer dlnaMappingObject:DLNAobj];- (BOOL)reconnectSocket;[self.moviePlayer reconnectSocket];- (void)playerBackgroundColor:(UIColor *)playerBgColor;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| playerBgColor | 是 | [UIColor redColor] | 颜色 |
[self.moviePlayer playerBackgroundColor:[UIColor blackColor]];- (void)playerBackgroundImage:(UIImage *)playerBgImage;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| playerBgImage | 是 | [UIImage new] | 图片 |
[self.moviePlayer playerBackgroundImage:[UIImage new]];+ (void)audioOutput:(BOOL)inSpeaker;| 参数名称 | 是否必须 | 示例 | 备注 |
|---|---|---|---|
| inSpeaker | 是 | YES | 音频类别 |
[self.moviePlayer audioOutput:YES];- (BOOL)openPIPSupported;[self.moviePlayer openPIPSupported];- (BOOL)closePIPSupported;[self.moviePlayer closePIPSupported];