# 7\_5-核心common-PPT

* [1 功能概述](#_1-功能概述)
* [2 核心类介绍](#_2-核心类介绍)
  * [2.1 对外API介绍](#_21-对外api介绍)
  * [2.2 代理回调介绍](#_22-代理回调介绍)
* [3 SDK核心类介绍](#_3-sdk核心类介绍)
  * [3.1 用PLVSocketManager收发服务端PPT消息](#_31-用plvsocketmanager收发服务端ppt消息)
  * [3.2 PPT使用的WebView](#_32-ppt使用的webview)
    * [3.2.1 对外API介绍](#_321-对外api介绍)
    * [3.2.2 代理回调介绍](#_322-代理回调介绍)

#### 1 功能概述

该模块位于文件夹 PolyvLiveCommonModule/Modules/PPT 下，是对SDK 层`PLVPPTWebview`的封装，该模块的信息接收依赖于socket，即要用 到SDK 层的 `PLVSocketManager`。

由`PLVPPTView`作为核心类来集成。

#### 2 核心类介绍

**2.1 对外API介绍**

`PLVInteractView`定义了如下几个需要在页面中使用的方法：

```objective-c
/// 设置视频SEI信息
///
/// @param newTimeStamp SEI信息
- (void)setSEIDataWithNewTimestamp:(long)newTimeStamp;

/// 加载回放PPT
///
/// @param vid 回放视频的vid
- (void)pptStart:(NSString *)vid;

/// PPT 恢复播放
///
/// @param currentTime 当前播放时间点
- (void)pptPlay:(long)currentTime;

/// PPT 暂停播放
///
/// @param currentTime 当前播放时间点
- (void)pptPause:(long)currentTime;

/// PPT 跳至某个播放点
///
/// @param toTime 需要跳至的播放时间点
- (void)pptSeek:(long)toTime;
```

**2.2 代理回调介绍**

```objective-c
@protocol PLVPPTViewDelegate <NSObject>

/// 获取刷新PPT的延迟时间
///
/// @note 不同场景下，PPT的刷新延迟时间不一，需向外部获知当前合适的延迟时间。
///
/// @param pptView PPT视图对象
///
/// @return unsigned int 返回刷新延迟时间 (单位:毫秒)
- (unsigned int)plvPPTViewGetPPTRefreshDelayTime:(PLVPPTView *)pptView;

/// PPT视图 PPT位置需切换
///
/// @note 直播场景中，收到此回调，表示讲师开播的默认PPT位置，或是 表示讲师发出切换PPT位置的指令；
///       回放场景中，将复现讲师对PPT的位置操作。收到此回调时，外部应根据 pptToMain 值相应切换PPT视图位置；
///
/// @param pptView PPT视图对象
/// @param pptToMain PPT是否需要切换至主窗口 (YES:PPT需要切至主窗口 NO:PPT需要切至小窗，视频需要切至主窗口)
- (void)plvPPTView:(PLVPPTView *)pptView changePPTPosition:(BOOL)pptToMain;

#pragma mark - 回放场景回调
/// [回放场景] PPT视图 需要获取视频播放器的当前播放时间点
///
/// @param pptView PPT视图对象
///
/// @return NSTimeInterval 当前播放时间点 (单位:毫秒)
- (NSTimeInterval)plvPPTViewGetPlayerCurrentTime:(PLVPPTView *)pptView;

@end
```

#### 3 SDK核心类介绍

**3.1 用PLVSocketManager收发服务端PPT消息**

核心common的PPT用到的SDK类是`PLVSocketManager`，利用该类既可以监听服务端老师发送的PPT事件。

具体可以参考`PLVPPTView`中对该类的使用。

**3.2 PPT使用的WebView**

PPT使用的是SDK提供的`PLVPPTWebview`类进行渲染的，对该类的使用均封装在了核心common的`PLVPPTView`类中。

**3.2.1 对外API介绍**

```objective-c
@interface PLVPPTWebview : UIView
 
#pragma mark - 配置属性
/// delegate
@property (nonatomic, weak) id <PLVPPTWebviewDelegate> delegate;

/// 直播场景，在 socket 登录成功后，需将用户信息同步至 PPT视图
@property (nonatomic, strong) NSDictionary * userInfo;

#pragma mark - 高级配置属性
/// jsbridge delegate
///
/// @note 当需要接收 webview 回调事件时，可设置此 jsDelegate
@property (nonatomic, weak) id <PLVJSBridgeDelegate> jsDelegate;

/// 是否自定义‘加载指示器’ (YES:内置加载指示器将不显示 NO:内置加载指示器将显示；默认 NO)
///
/// @note 需同时设置 jsDelegate，以接收对应的回调。回调介绍，具体请参考 <PLVJSBridgeDelegate>
@property (nonatomic, assign) BOOL customActivityIndicator;

/// 调试模式 (YES:打印调试信息 NO:不打印调试信息；默认 NO)
@property (nonatomic, assign) BOOL jsDebugMode;

#pragma mark - 页面加载
/// 加载在线 互动页面
- (void)loadOnlinePPT;

/// 加载本地 互动页面
///
/// @param htmlString 本地 html 解析后内容
/// @param baseURL 可访问的文件夹路径 (注意是 file:// 开头的 URL)
- (void)loadLocalPPTWithHTMLString:(NSString *)htmlString baseURL:(NSURL *)baseURL;

/// 加载本地 html 文件
///
/// @note 该方法要求 iOS9 以上；对本地文件读取的兼容性更好
///
/// @param URL html 本地文件路径 (注意是 file:// 开头的 URL)
/// @param readAccessURL 可访问的文件夹路径 (注意是 file:// 开头的 URL)
- (void)loadLocalPPTWithFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL API_AVAILABLE(ios(9.0));

#pragma mark - 直播场景相关方法
/// 刷新PPT内容
///
/// @param json PPT内容
- (void)refreshPPT:(NSString *)json;

/// 刷新PPT内容
///
/// @param json PPT内容
/// @param delay 延迟时间 (单位毫秒)
- (void)refreshPPT:(NSString *)json delay:(NSUInteger)delay;

/// 设置视频SEI信息
///
/// @param json SEI信息
- (void)setSEIData:(NSString *)json;

#pragma mark - 双向画笔相关方法
/// 设置画笔相关权限
///
/// @param paint 画笔权限 (YES:允许使用 NO:禁用)
/// @param control 操作ppt权限 (YES:允许使用 NO:禁用)
- (void)setPaintPermission:(BOOL)paint controlPPTPermission:(BOOL)control;

/// 设置画板可绘制状态
///
/// @param status 可绘制状态 (close:关闭画笔 open:开启画笔)
- (void)setPaintStatus:(NSString *)status;

/// 设置画笔颜色
///
/// @param color 画笔颜色色值字符串
- (void)setBrushColor:(NSString *)color;

/// 开启画笔删除状态
- (void)toDelete;

#pragma mark - 回放场景相关方法
/// 加载回放PPT
///
/// @param vid 回放视频的vid
- (void)pptStart:(NSString *)vid;

/// PPT 恢复播放
///
/// @param currentTime 当前播放时间点
- (void)pptPlay:(long)currentTime;

/// PPT 暂停播放
///
/// @param currentTime 当前播放时间点
- (void)pptPause:(long)currentTime;

/// PPT 跳至某个播放点
///
/// @param toTime 需要跳至的播放时间点
- (void)pptSeek:(long)toTime;

@end
```

**3.2.2 代理回调介绍**

```objective-c
@protocol PLVPPTWebviewDelegate <NSObject>

@optional

#pragma mark - 通用回调
/// PPT视图 已准备完毕
///
/// @param pptWebview PPT视图对象
- (void)plvPPTWebviewHadPrepared:(PLVPPTWebview *)pptWebview;


#pragma mark - 直播场景回调
/// [直播场景] PPT视图 发送笔触数据
///
/// @note 开启画笔权限的连麦学员，在操作绘画后，需将生成的笔触数据，回调给外部处理；
///
/// @param pptWebview PPT视图对象
/// @param jsonData PPT视图对象
- (void)plvPPTWebview:(PLVPPTWebview *)pptWebview sendPaintInfo:(NSString *)jsonData;


#pragma mark - 回放场景回调
/// [回放场景] PPT视图 需要获取视频播放器的当前播放时间点
///
/// @param pptWebview PPT视图对象
///
/// @return NSTimeInterval 当前播放时间点
- (NSTimeInterval)plvPPTWebviewGetPlayerCurrentTime:(PLVPPTWebview *)pptWebview;

/// [回放场景] PPT视图 讲师发起PPT位置切换
///
/// @note 回放中，将复现讲师对PPT的位置操作。收到此回调时，外部应根据 status 值相应切换PPT视图位置
///
/// @param pptWebview PPT视图对象
/// @param status PPT是否需要切换至主窗口 (YES:PPT需要切至主窗口 NO:PPT需要切至小窗，视频需要切至主窗口)
- (void)plvPPTWebview:(PLVPPTWebview *)pptWebview changePPTPosition:(BOOL)status;

@end
```


---

# 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/75-he-xin-commonppt.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.
