# 2-快速集成

#### 1 账号准备

在集成播放器 SDK 项目之前，请先在[Polyv 官网](http://www.polyv.net/)注册账号，并开通云点播服务。

为了播放您账号下的点播视频，播放器将需要使用到您点播系统中的`userId`和`secretKey`，您可以登录点播后台，在[API 接口](https://my.polyv.net/secure/setting/api)中获取参数。

#### 2 环境要求

| 名称        | 要求          |
| --------- | ----------- |
| iOS 系统    | iOS 12.0+   |
| CocoaPods | 1.7.0+      |
| 集成工具      | Xcode 11.0+ |

#### 3 集成播放器项目

**3.1 导入通用模块**

拷贝 demo 项目中的`Common`模块到您项目的根目录下

**3.2 导入Secenes 通用模块**

拷贝 demo 项目中的`Secenes` 模块到您项目的根目录下

**3.5 配置 Podfile**

在 Podfile 文件中，添加以下内容：

```ruby
  pod 'PolyvMediaPlayerSDK', '~> 2.2.0'

  pod 'SDWebImage', '4.4.0'
  pod 'MJRefresh', '~> 3.5.0'
```

**3.5 跳转播放页面**

Secenes 模块提供了 2 个页面，分别是：

1. `PLVDemoVideoFeedViewController`是短视频播放页面，支持上下滑动切换的沉浸式观看方式
2. `PLVDemoVodMediaViewController`是长视频播放页面，支持单视频的横竖屏播放方式

您可以根据项目实际需要，选择其中一个页面作为播放页面，然后在您项目的任意页面跳转到播放页面。

而demo项目中`PLVEntranceViewController`是项目演示的入口页面，演示了如何跳转到短视频播放页面或者长视频播放页面。

**3.6 参数修改**

为了播放您账号下的视频，您需要对项目默认配置的参数进行修改。

demo 项目中，默认配置的视频数据在`AppDelegate.m`当中，您可以对其中`initMediaPlayerSDK` 的参数进行修改：

```objectivec
- (void)initMediaPlayerSDK {
    // 配置APP账号
    // 公共账号
    // 注意: 2.1.x版本以下应为PLVVodSettings，请以实际版本情况调用。
    PLVVodMediaSettings *settings = [PLVVodMediaSettings settingsWithUserid:@"e97dbe3e64"
                                                        readtoken:@""
                                                       writetoken:@""
                                                        secretkey:@"zMV29c519P"];

    settings.logLevel = PLVVodMediaLogLevelAll;
    settings.viewerInfos.viewerId = @"用户";
    settings.viewerInfos.viewerName = @"User Name";
    settings.viewerInfos.viewerAvatar = @"User Avatar Link";
    settings.viewerInfos.viewerExtraInfo1 = @"Custom param3";
    settings.viewerInfos.viewerExtraInfo2 = @"Custom param4";
    settings.viewerInfos.viewerExtraInfo3 = @"Custom param5";
}
```

同时demo项目中，长视频默认配置了可播放的视频，您可以在`PLVEntranceViewController.m`当中调整初始化的视频Id。

```objectivec
// 长视频观看
- (void)watchVodButtonAction:(id)sender {
    PLVDemoVodMediaViewController *vodMediaVC = [[PLVDemoVodMediaViewController alloc] init];
    if (PushOrModel) {
        vodMediaVC.hidesBottomBarWhenPushed = YES;
        vodMediaVC.vid = @"e97dbe3e648aefc2eb6f68b96db9db6c_e"; // 替换自身项目Id
        [self.navigationController pushViewController:vodMediaVC animated:YES];
    }else{
        vodMediaVC.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentViewController:vodMediaVC animated:YES completion:nil];
    }
}
```


---

# 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/vod/ios_player_sdk/2-kuai-su-ji-cheng.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.
