| 属性 | 属性描述 |
|---|---|
| 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];- (void)setIsOpenPIP:(BOOL)isOpenPIP;[self.moviePlayer setIsOpenPIP:YES];前提需使用方法"preLoadRoomWithParam",收到此回调后,可以使用聊天、签到、问答、抽奖等功能,择机调用startPlay/startPlayback进行播放(可以实现在调用播放之前使用聊天等功能)
- (void)preLoadVideoFinish:(VHallMoviePlayer *)moviePlayer
activeState:(VHMovieActiveState)activeState
error:(NSError*)error;| 参数名称 | 备注 |
|---|---|
| activeState | 活动状态 |
| error | 非空即预加载成功 |
前提需使用方法"startPlay/startPlayback",收到此回调后,可以使用聊天、签到、问答、抽奖等功能
- (void)connectSucceed:(VHallMoviePlayer *)moviePlayer
info:(NSDictionary *)info;| 参数名称 | 备注 |
|---|---|
| info | 相关信息 |
- (void)liveDidStart:(VHallMoviePlayer *)moviePlayer;- (void)liveDidStoped:(VHallMoviePlayer *)moviePlayer;- (void)bufferStart:(VHallMoviePlayer *)moviePlayer
info:(NSDictionary *)info;| 参数名称 | 备注 |
|---|---|
| info | 相关信息 |
- (void)bufferStop:(VHallMoviePlayer *)moviePlayer
info:(NSDictionary *)info;| 参数名称 | 备注 |
|---|---|
| info | 相关信息 |
- (void)downloadSpeed:(VHallMoviePlayer *)moviePlayer
info:(NSDictionary *)info;| 参数名称 | 备注 |
|---|---|
| info | 相关信息 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
recStreamTypeInfo:(NSDictionary *)info;| 参数名称 | 备注 |
|---|---|
| info | 相关信息 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
playError:(VHSaasLivePlayErrorType)livePlayErrorType
info:(NSDictionary *)info;| 参数名称 | 备注 |
|---|---|
| livePlayErrorType | 直播错误类型 |
| info | 相关信息 |
| 参数名称 | 备注 |
|---|---|
| VHSaasLivePlayErrorNone | |
| VHSaasLivePlayParamError | 参数错误 |
| VHSaasLivePlayRecvError | 接受数据错误 |
| VHSaasLivePlayCDNConnectError | CDN链接失败 |
| VHSaasVodPlayError | 点播播放器错误信息 |
| VHSaasLivePlayGetUrlError | 获取活动信息失败 |
| VHSaasPlaySSOKickout | 观看被踢出 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
activeStateDidChange:(VHMovieActiveState)activeState;| 参数名称 | 备注 |
|---|---|
| VHMovieActiveStateNone | |
| VHMovieActiveStateLive | 直播 |
| VHMovieActiveStateReservation | 预约 |
| VHMovieActiveStateEnd | 结束 |
| VHMovieActiveStateReplay | 回放or点播 |
当前视频播放模式,以及是否为vr活动回调
- (void)moviePlayer:(VHallMoviePlayer *)player
loadVideoPlayMode:(VHMovieVideoPlayMode)playMode
isVrVideo:(BOOL)isVrVideo;| 参数名称 | 备注 |
|---|---|
| playMode | 视频播放模式 |
| isVrVideo | 是否为vr活动 |
| 参数名称 | 备注 |
|---|---|
| VHMovieVideoPlayModeNone | 不存在 |
| VHMovieVideoPlayModeMedia | 单视频 |
| VHMovieVideoPlayModeTextAndVoice | 文档+声音 |
| VHMovieVideoPlayModeTextAndMedia | 文档+视频 |
| VHMovieVideoPlayModeVoice | 单音频 |
- (void)moviePlayer:(VHallMoviePlayer *)player
loadVideoPlayModeList:(NSArray *)playModeList;| 参数名称 | 备注 |
|---|---|
| playModeList | VHMovieVideoPlayMode播放模式组合,如@[@(VHMovieVideoPlayModeMedia),@(VHMovieVideoPlayModeVoice)] |
- (void)moviePlayer:(VHallMoviePlayer *)player
loadVideoDefinitionList:(NSArray *)definitionList;| 参数名称 | 备注 |
|---|---|
| definitionList | VHDefinition清晰度组合,如@[@(VHDefinitionOrigin),@(VHDefinitionUHD),@(VHDefinitionHD)] |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
statusDidChange:(VHPlayerState)state;| 参数名称 | 备注 |
|---|---|
| state | 播放器状态 |
| 参数名称 | 备注 |
|---|---|
| VHPlayerStateStoped | 停止 可调用startPlay: startPlayback: 状态转为VHallPlayerStateStarting |
| VHPlayerStateStarting | 启动中 |
| VHPlayerStatePlaying | 播放中 可调用stopPlay pausePlay 状态转为VHallPlayerStateStoped/VHallPlayerStatePaused |
| VHPlayerStateStreamStoped | 直播流停止 暂停pausePlay/流连接错误触发 可调用stopPlay reconnectPlay状态转为VHallPlayerStateStoped/VHallPlayerStatePlaying |
| VHPlayerStatePause | 回放暂停状态 |
| VHPlayerStateComplete | 回放播放完成 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
videoSize:(CGSize)size;| 参数名称 | 备注 |
|---|---|
| size | 视频尺寸 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
isInteractiveActivity:(BOOL)isInteractive
interactivePermission:(VHInteractiveState)state;| 参数名称 | 备注 |
|---|---|
| isInteractive | 当前活动是否支持互动功能 |
| state | 主持人是否允许举手 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
microInvitationWithAttributes:(NSDictionary *)attributes
error:(NSError *)error;| 参数名称 | 备注 |
|---|---|
| attributes | 收到的数据 |
| error | nil:同意上麦 非nil:不同意上麦 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
microInvitation:(NSDictionary *)attributes;| 参数名称 | 备注 |
|---|---|
| attributes | 收到的数据 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
isKickout:(BOOL)isKickout;| 参数名称 | 备注 |
|---|---|
| isKickout | 被踢出 (取消踢出后需要重新进入) |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
isCast_screen:(BOOL)isCast_screen;| 参数名称 | 备注 |
|---|---|
| isCast_screen | 1支持 0不支持 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
isHaveDocument:(BOOL)isHave
isShowDocument:(BOOL)isShow;| 参数名称 | 备注 |
|---|---|
| isHave | YES 此活动有文档演示 |
| isShow | YES 主持人显示观看端文档,NO 主持人隐藏观看端文档 |
直播文档有延迟,指定需要延迟的秒数 (默认为直播缓冲时间,即:realityBufferTime/1000.0)
- (NSTimeInterval)documentDelayTime:(VHallMoviePlayer *)moviePlayer;- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
announcementContentDidChange:(NSString*)content
publishTime:(NSString*)time;| 参数名称 | 备注 |
|---|---|
| content | 公告内容 |
| time | 发布时间 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer
isQuestion_status:(BOOL)isQuestion_status
question_name:(NSString *)questionName;| 参数名称 | 备注 |
|---|---|
| isQuestion_status | 1开启 0关闭 |
| questionName | v6.4 新增问答名称 |
- (void)moviePlayer:(VHallMoviePlayer *)moviePlayer is_file_download:(BOOL)is_file_download file_download_menu:(VHallPlayMenuModel *)file_download_menu;| 参数名称 | 备注 |
|---|---|
| is_file_download | 是否开启 1开启 0关闭 |
| file_download_menu | 文件下载菜单详情 |
- (void)pictureInPictureControllerWillStart;- (void)pictureInPictureControllerDidStart;- (void)pictureInPictureWithFailedToStartPictureInPictureWithError:(NSError *)error;