# 3\_4-云课堂场景-PPT

* [1 功能概述](#_1-功能概述)
* [2 初始化](#_2-初始化)
* [3 播放](#_3-播放)
* [4 代理回调处理](#_4-代理回调处理)
* [5 浮窗](#_5-浮窗)

#### 1 功能概述

云课堂场景PPT是直播同步讲师端PPT信息、回放历史PPT信息，该功能是在`PLVLCMediaAreaView`中实现，集成[7\_5 核心common-PPT](https://git.polyv.net/help-center/document-center/-/blob/master/live/ios/7_5-核心common-PPT/README.md)中`PLVPPTView`来实现的功能。

#### 2 初始化

```objective-c
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 播放

```objective-c
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 代理回调处理

实现`PLVPPTViewDelegate`代理方法，代码如下：

```objective-c
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 浮窗

云课堂场景中播放器和PPT分别在主屏（房间顶部显示区域`PLVLCMediaAreaView`）和浮窗`PLVLCMediaFloatView`中，点击浮窗时播放器和PPT互换位置的功能；

浮窗`PLVLCMediaFloatView`对象在`PLVLCMediaAreaView`中初始化并持有，显示是添加`PLVLCCloudClassViewController`的view上显示的。

具体代码可查看Demo中`PLVLCCloudClassViewController.m`和`PLVLCMediaAreaView.m`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyv.gitbook.io/document/docs/live/ios/34-yun-ke-tang-chang-jing-ppt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
