#import <VHLiveSDK/VHallApi.h>
@interface VHFashionStyleWatchLiveVC ()<VHallChatDelegate>
/// 播放器
@property (nonatomic, strong) VHallMoviePlayer * moviePlayer;
/// 聊天
@property (nonatomic, strong) VHallChat * chat;
@end
@implementation VHFashionStyleWatchLiveVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// 在收到"播放连接成功回调"后,才能使用聊天、签到等功能
[self.moviePlayer startPlay:[self playParam]];
}
#pragma mark - -----------------VHallMoviePlayer 播放器状态相关--------------------
// 播放连接成功
- (void)connectSucceed:(VHallMoviePlayer *)moviePlayer info:(NSDictionary *)info
{
VHLog(@"播放连接成功:%@",info);
// 设置聊天代理
self.chat.delegate = self;
}
#pragma mark - ----------------------VHallChatDelegate----------------------
// 收到上下线消息
- (void)reciveOnlineMsg:(NSArray <VHallOnlineStateModel *> *)msgs
{
for (VHallOnlineStateModel * m in msgs) {
NSString * content = [NSString stringWithFormat:@"在线:%@ 参会:%@",m.concurrent_user, m.attend_count];
VHLog(@"%@",content);
}
}
// 收到虚拟人数消息
- (void)vhBaseNumUpdateToUpdate_online_num:(NSInteger)update_online_num
update_pv:(NSInteger)update_pv
{
// 增加的虚拟人数和虚拟热度
NSString * content = [NSString stringWithFormat:@"在线人数增加了%ld, 在线热度增加了%ld",update_online_num,update_pv];
VHLog(@"%@",content);
}
#pragma mark - 懒加载
- (VHallMoviePlayer *)moviePlayer
{
if (!_moviePlayer) {
_moviePlayer = [[VHallMoviePlayer alloc] initWithDelegate:self];
_moviePlayer.movieScalingMode = VHRTMPMovieScalingModeAspectFit;
_moviePlayer.defaultDefinition = VHMovieDefinitionHD;
[self addSubview:_moviePlayer.moviePlayerView];
}return _moviePlayer;
}
- (VHallChat *)chat
{
if (!_chat) {
_chat = [[VHallChat alloc] initWithObject:self.moviePlayer];
}return _chat;
}
@end