Polyv Help Center

Help Center

2.快速集成

Updated: 2024-06-04 17:16:31

1 Account Preparation

Before integrating the Player SDK project, please register an account on the Polyv website and activate the cloud video-on-demand service.

To play on-demand videos under your account, the player will need the userId and secretKey from your video-on-demand system. You can log in to the on-demand backend and obtain these parameters in the API Interface.

2 Environment Requirements

Name Requirement
iOS System iOS 12.0+
CocoaPods 1.7.0+
Integration Tool Xcode 11.0+

3 Integrating the Player Project

3.1 Import the Common Module

Copy the Common module from the demo project to the root directory of your project.

3.2 Import the Scenes Common Module

Copy the Secenes module from the demo project to the root directory of your project.

3.5 Configure Podfile

Add the following content to the Podfile:

  pod 'PolyvMediaPlayerSDK', '~> 2.2.0'

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

3.5 Navigate to the Playback Page

The Scenes module provides two pages:

  1. PLVDemoVideoFeedViewController is a short video playback page, supporting an immersive viewing experience with vertical swipe navigation.
  2. PLVDemoVodMediaViewController is a long video playback page, supporting single video playback in both portrait and landscape orientations.

You can select one of these pages as the playback page based on your project's needs, and then navigate to it from any page in your project.

In the demo project, PLVEntranceViewController serves as the entry page for project demonstrations, showing how to navigate to either the short video playback page or the long video playback page.

3.6 Parameter Modification

To play videos under your account, you need to modify the default configuration parameters in the project.

In the demo project, the default video data is configured in AppDelegate.m. You can modify the parameters of initMediaPlayerSDK as follows:

- (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";
}

Additionally, in the demo project, the long video page is pre-configured with playable videos. You can adjust the initialized video ID in PLVEntranceViewController.m.

// 长视频观看
- (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];
    }
}
联系客服,在线咨询
在线咨询