Polyv Help Center

Help Center

3_4-云课堂场景-PPT

Updated: 2023-04-17 15:27:57

1 Feature Overview

In the cloud classroom scenario, PPT synchronizes the instructor's PPT information during live streaming and historical PPT information during playback. This feature is implemented in PLVLCMediaAreaView and integrates the functionality of PLVPPTView from 7_5 Core Common-PPT.

2 Initialization

PLVLCMediaAreaView.m

- (PLVPPTView *)pptView{
    if (!_pptView && self.channelType != PLVChannelTypeAlone) {
        _pptView = [[PLVPPTView alloc] init];
        _pptView.delegate = self;
        _pptView.backgroudImageView.image = [self getImageWithName:@"plvlc_media_ppt_placeholder"];
    }
    return _pptView;
}

3 Playback

PLVLCMediaAreaView.m

- (void)setupModule{
    /// 注意:懒加载过程中(即Getter),已增加判断,若场景不匹配,将创建失败并返回nil
    if (self.videoType == PLVChannelVideoType_Live) { // 视频类型为 直播
        /// 直播 模块
                /// ...
         
        /// PPT模块
        [self.floatView displayExternalView:self.pptView]; /// 无直播时的默认状态,是‘PPT画面’位于副屏(悬浮小窗)
        
    }else if (self.videoType == PLVChannelVideoType_Playback){ // 视频类型为 直播回放
        /// 直播回放 模块
                /// ...
                
        /// PPT模块
        [self.floatView displayExternalView:self.pptView]; /// 默认状态,是‘PPT画面’位于副屏(悬浮小窗)
        [self.floatView showFloatView:YES userOperat:NO];
        [self.pptView pptStart:[PLVRoomDataManager sharedManager].roomData.vid];
        
    }
}

/// 播放器 ‘SEI信息’ 发生改变
- (void)playerPresenter:(PLVPlayerPresenter *)playerPresenter seiDidChange:(long)timeStamp newTimeStamp:(long)newTimeStamp{
    [self.pptView setSEIDataWithNewTimestamp:newTimeStamp];
}

4 Proxy Callback Handling

Implement the PLVPPTViewDelegate proxy method. The code is as follows:

PLVLCMediaAreaView.m

- (unsigned int)plvPPTViewGetPPTRefreshDelayTime:(PLVPPTView *)pptView{
    return self.inRTCRoom ? 0 : 5000;
}

/// PPT视图 PPT位置需切换
- (void)plvPPTView:(PLVPPTView *)pptView changePPTPosition:(BOOL)pptToMain{
    if (self.videoType == PLVChannelVideoType_Live){ // 视频类型为 直播
        /// 仅在 非观看RTC场景下 执行 (观看RTC场景下,由 PLVLCLinkMicAreaView 自行处理)
        if (self.inRTCRoom == NO) {
            if (pptToMain != self.pptOnMainSite) {
                [self.floatView triggerViewExchangeEvent];
            }
        }
    } else if (self.videoType == PLVChannelVideoType_Playback) { // 视频类型为 直播回放
        if (pptToMain != self.pptOnMainSite) {
            [self.floatView triggerViewExchangeEvent];
        }
    }
}

/// [回放场景] PPT视图 需要获取视频播放器的当前播放时间点
- (NSTimeInterval)plvPPTViewGetPlayerCurrentTime:(PLVPPTView *)pptView{
    return self.playerPresenter.currentPlaybackTime * 1000;
}

5 Floating Window

In the cloud classroom scenario, the player and PPT are displayed in the main screen (the room's top display area PLVLCMediaAreaView) and the floating window PLVLCMediaFloatView, respectively. Clicking the floating window swaps the positions of the player and PPT.

The floating window PLVLCMediaFloatView object is initialized and held in PLVLCMediaAreaView, and it is displayed by adding it to the view of PLVLCCloudClassViewController.

For specific code, refer to PLVLCCloudClassViewController.m and PLVLCMediaAreaView.m in the Demo.

联系客服,在线咨询