3_6-云课堂场景-互动

1 功能概述

互动功能包括公告、签到、抽奖、答题卡、和问卷功能。该功能是在PLVLCCloudClassViewControllerr中实现,集成7_6-核心common-互动PLVInteractView来实现的功能。

2 实现介绍

云课堂场景互动功能只需要在 页面 中加入PLVInteractView,并调用其初始化方法,即可完成集成。

在接收到主播端发起的抽奖等功能时,互动应用界面将会自动显示。

示例代码如下

/// PLVLCCloudClassViewControllerr.m

@property (nonatomic, strong) PLVInteractView *interactView; // 互动

- (void)setupModule{
    PLVRoomData *roomData = [PLVRoomDataManager sharedManager].roomData;
    if (roomData.videoType == PLVChannelVideoType_Live) {
				/// 直播
				/// 注册互动通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationForOpenBulletin:) name:PLVLEChatroomOpenBulletinNotification object:nil];
        
    } else if (roomData.videoType == PLVChannelVideoType_Playback){
    		/// 回放
    }
}

- (void)setupUI{
    if (roomData.videoType == PLVChannelVideoType_Live) {
        /// 直播
        
        /// 互动
        [self.view addSubview:self.interactView];

        /// 互动配置
        self.interactView.frame = self.view.bounds;
        self.interactView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.interactView loadOnlineInteract];
        
    } else if (roomData.videoType == PLVChannelVideoType_Playback){
        /// 回放
    }
}

- (PLVInteractView *)interactView{
    PLVChannelVideoType videoType = [PLVRoomDataManager sharedManager].roomData.videoType;
    if (!_interactView && videoType == PLVChannelVideoType_Live) {
        _interactView = [[PLVInteractView alloc] init];
        _interactView.frame = self.view.bounds;
        _interactView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [_interactView loadOnlineInteract];
    }
    return _interactView;
}

- (void)notificationForOpenBulletin:(NSNotification *)notif {
    [self.interactView openLastBulletin];
}

Last updated