|
|
## VR功能接入文档
|
|
|
|
|
|
[TOC]
|
|
|
|
|
|
### 接入方式
|
|
|
|
|
|
```shell
|
|
|
pod 'HDSPanoramicVideoFramework'
|
|
|
pod 'HDSVRMediaFramework' //VR播放器
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 新增API
|
|
|
|
|
|
#### 创建全景视频(推荐)
|
|
|
|
|
|
| 方法 | 说明 | 所在类 |
|
|
|
| --------------------------------- | ------------ | -------------------------- |
|
|
|
| (void)createWithConfig: playView: | 创建全景视频 | HDSPanoramicVideoCreator.h |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
/// 创建全景视频(推荐)
|
|
|
/// - Parameters:
|
|
|
/// - config: 配置项
|
|
|
/// - playerView: 播放器视图
|
|
|
- (void)createWithConfig:(HDSPanoramicVideoConfig * _Nonnull)config playView:(UIView * _Nonnull)playerView;
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### 创建全景视频
|
|
|
|
|
|
| 方法 | 说明 | 所在类 |
|
|
|
| --------------------------------------------- | ------------ | -------------------------- |
|
|
|
| (void)createWithConfig: playView: playerItem: | 创建全景视频 | HDSPanoramicVideoCreator.h |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
/// 创建全景视频
|
|
|
/// - Parameters:
|
|
|
/// - config: 配置项
|
|
|
/// - playerView: 播放器视图
|
|
|
/// - playerItem: playerItem
|
|
|
- (void)createWithConfig:(HDSPanoramicVideoConfig * _Nonnull)config playView:(UIView * _Nonnull)playerView playerItem:(AVPlayerItem * _Nonnull)playerItem;
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### 切换展示模式
|
|
|
|
|
|
| 方法 | 说明 | 所在类 |
|
|
|
| ------------------------ | ------------ | -------------------------- |
|
|
|
| (void)changeDisplayMode: | 切换展示模式 | HDSPanoramicVideoCreator.h |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
/// 切换展示模式
|
|
|
/// - Parameter displayMode: 展示模式
|
|
|
- (void)changeDisplayMode:(HDSDisplayMode)displayMode;
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### 切换互动模式
|
|
|
|
|
|
| 方法 | 说明 | 所在类 |
|
|
|
| ---------------------------- | ------------ | -------------------------- |
|
|
|
| (void)changeInteractiveMode: | 切换互动模式 | HDSPanoramicVideoCreator.h |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
/// 切换互动模式
|
|
|
/// - Parameter interactiveMode: 互动模式
|
|
|
- (void)changeInteractiveMode:(HDSInteractiveMode)interactiveMode;
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 新增参数
|
|
|
|
|
|
#### HDSPanoramicVideoConfig
|
|
|
|
|
|
| 参数 | 类型 | 说明 | 所在类 |
|
|
|
| --------------- | ------------------ | -------- | ------------------------- |
|
|
|
| targetVC | UIViewController | 目标VC | HDSPanoramicVideoConfig.h |
|
|
|
| pinchEnabled | Bool | 捏合手势 | HDSPanoramicVideoConfig.h |
|
|
|
| displayMode | HDSDisplayMode | 展示模式 | HDSPanoramicVideoConfig.h |
|
|
|
| interactiveMode | HDSInteractiveMode | 互动模式 | HDSPanoramicVideoConfig.h |
|
|
|
|
|
|
|
|
|
|
|
|
##### HDSDisplayMode
|
|
|
|
|
|
| 参数 | 说明 | 所在类 |
|
|
|
| --------------------- | -------- | ------------------------- |
|
|
|
| HDSDisplayModeNormal | 默认 | HDSPanoramicVideoConfig.h |
|
|
|
| HDSDisplayModeGlasses | 眼镜模式 | HDSPanoramicVideoConfig.h |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
typedef NS_ENUM(NSUInteger, HDSDisplayMode) {
|
|
|
HDSDisplayModeNormal, //默认
|
|
|
HDSDisplayModeGlasses, //眼镜模式
|
|
|
};
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
##### HDSInteractiveMode
|
|
|
|
|
|
| 参数 | 说明 | 所在类 |
|
|
|
| --------------------------------- | ------------- | ------------------------- |
|
|
|
| HDSInteractiveModeTouch | 触摸 | HDSPanoramicVideoConfig.h |
|
|
|
| HDSInteractiveModeMotion | 重力感应 | HDSPanoramicVideoConfig.h |
|
|
|
| HDSInteractiveModeMotionWithTouch | 触摸+重力感应 | HDSPanoramicVideoConfig.h |
|
|
|
|
|
|
示例代码
|
|
|
|
|
|
```objc
|
|
|
typedef NS_ENUM(NSUInteger, HDSInteractiveMode) {
|
|
|
HDSInteractiveModeTouch, //触摸
|
|
|
HDSInteractiveModeMotion, //重力感应
|
|
|
HDSInteractiveModeMotionWithTouch, //触摸+重力感应
|
|
|
};
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### 使用方式(以CCSDK为例)
|
|
|
|
|
|
```objc
|
|
|
// 1. 初始化SDK
|
|
|
- (void)initSDK {
|
|
|
__weak typeof(self) weakSelf = self;
|
|
|
SDK = [[RequestData alloc] initSDKWithParameter:_parameter succed:^(BOOL succed) {
|
|
|
|
|
|
} player:^(UIView * _Nonnull playerView) {
|
|
|
...
|
|
|
// 3. 创建VR库
|
|
|
if (weakSelf.VRRoom) {
|
|
|
[weakSelf createVRLibrary:playerView];
|
|
|
}
|
|
|
...
|
|
|
} failed:^(NSError * _Nullable error, NSString * _Nonnull reason) {
|
|
|
|
|
|
}];
|
|
|
SDK.delegate = self;
|
|
|
}
|
|
|
|
|
|
// 2. 判断VR开关
|
|
|
- (void)onRoomConfigure:(HDSRoomConfigureModel * _Nonnull)configure {
|
|
|
self.VRRoom = configure.VRSwitch;
|
|
|
}
|
|
|
|
|
|
// 3. 创建VR库
|
|
|
- (void)createVRLibrary:(UIView *)playerView {
|
|
|
if (_creator) {
|
|
|
_creator = nil;
|
|
|
}
|
|
|
HDSPanoramicVideoConfig *config = [[HDSPanoramicVideoConfig alloc]init];
|
|
|
config.targetVC = self;
|
|
|
config.displayMode = HDSDisplayModeNormal;
|
|
|
config.interactiveMode = HDSInteractiveModeMotionWithTouch;
|
|
|
config.pinchEnabled = YES;
|
|
|
self.creator = [[HDSPanoramicVideoCreator alloc]init];
|
|
|
[_creator createWithConfig:config playView:playerView];
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |