Polyv Help Center

Help Center

playerSettingsService

Updated: 2023-09-22 17:47:34

1. Query All Player Lists Under a User

Description

查询用户下所有播放器列表
接口地址(仅做说明使用):https://api.polyv.net/v2/play/%s/player-list

Call Constraints

  1. The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.

Unit Test

    @Test
    public void testGetPlayerList() throws IOException, NoSuchAlgorithmException {
        VodGetPlayerListRequest vodGetPlayerListRequest = new VodGetPlayerListRequest();
        List<VodGetPlayerListResponse> vodGetPlayerListResponseList = null;
        try {
            vodGetPlayerListResponseList = new VodPlayerSettingsServiceImpl().getPlayerList(vodGetPlayerListRequest);
            Assert.assertNotNull(vodGetPlayerListResponseList);
            if (vodGetPlayerListResponseList != null) {
                log.debug("测试查询用户下所有播放器列表成功,{}", JSON.toJSONString(vodGetPlayerListResponseList));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a VodGetPlayerListResponse object is returned, and the B-side processes business logic based on this object.

  2. If the request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failure field [pic cannot be empty / msg cannot be empty]].

  3. If the server processes abnormally, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

This method uses system-wide configuration and does not require explicit parameter passing.

Return Object Description

The return object is List<VodGetPlayerListResponse>. The specific elements of VodGetPlayerListResponse are as follows:

Parameter Name Type Description
playerName String Player name
playerId String Player ID
createTime Date Creation time, format: yyyy-MM-dd HH:mm:ss [corresponds to the date field in the API documentation]
isDefault Integer Whether it is the default player: 1 for yes, 0 for no






2. Set the Player for a Video

Description

设置视频的播放器
接口地址(仅做说明使用):https://api.polyv.net/v2/play/set-video-player

Call Constraints

  1. The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.

Unit Test

    @Test
    public void testSetVideoPlayer() throws IOException, NoSuchAlgorithmException {
        VodSetVideoPlayerRequest vodSetVideoPlayerRequest = new VodSetVideoPlayerRequest();
        Boolean vodSetVideoPlayerResponse = null;
        try {
            vodSetVideoPlayerRequest.setVideoId(super.getTestVideoId()).setPlayerId("MDL7ARoayp");
            vodSetVideoPlayerResponse = new VodPlayerSettingsServiceImpl().setVideoPlayer(vodSetVideoPlayerRequest);
            Assert.assertTrue(vodSetVideoPlayerResponse);
            if (vodSetVideoPlayerResponse) {
                log.debug("设置视频的播放器成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-side processes business logic based on this object.

  2. If the request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failure field [pic cannot be empty / msg cannot be empty]].

  3. If the server processes abnormally, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
videoId true String Video ID [corresponds to the vid field in the API documentation]
playerId true String Player ID

Return Object Description

null




3. Get Playsafe Token

Description

通过用户id与视频id获取播放凭证,用于播放加密视频
接口地址(仅做说明使用):https://hls.videocc.net//service/v1/token

Call Constraints

  1. The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.

  2. If a token (playback credential) has not expired, and the same videoId, viewerId, viewerIp, and isWxa parameter values are used to request this interface, the original token will be reused, and its validity period will be extended.

Unit Test

    @Test
    public void testGetPlaySafeToken() throws IOException, NoSuchAlgorithmException {
        VodGetPlaySafeTokenRequest vodGetPlaySafeTokenRequest = new VodGetPlaySafeTokenRequest();
        VodGetPlaySafeTokenResponse vodGetPlaySafeTokenResponse = null;
        try {
            vodGetPlaySafeTokenRequest.setVideoId("1b448be323b68b2999802799a98dba54_1")
                    .setViewerId("testViewerId")
                    .setViewerIp(super.getRandomIp())
                    .setViewerName("TestViewName")
                    .setExpires(Long.parseLong("60"))
                    .setDisposable(Boolean.TRUE)
                    .setIsWxa(0);
            vodGetPlaySafeTokenResponse = new VodPlayerSettingsServiceImpl().getPlaySafeToken(
                    vodGetPlaySafeTokenRequest);
            Assert.assertNotNull(vodGetPlaySafeTokenResponse);
            if (vodGetPlaySafeTokenResponse != null) {
                log.debug("测试获取Playsafe Token成功,{}", JSON.toJSONString(vodGetPlaySafeTokenResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a VodGetPlaySafeTokenResponse object is returned, and the B-side processes business logic based on this object.

  2. If the request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failure field [pic cannot be empty / msg cannot be empty]].

  3. If the server processes abnormally, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
videoId true String Video ID, e.g., e6b23c6f519c5906e54a13b8200d7bb0_e
viewerId true String Viewer ID, different viewers must use different IDs
viewerIp false String Viewer IP. If empty, the IP used to call the interface will be automatically obtained
viewerName false String Viewer name
expires false Long Token validity period in seconds. Default is 10 minutes if empty
disposable false Boolean Token validity: true means the token is valid only once (invalid after one verification), false means it can be verified multiple times within the validity period. Default is false
isWxa false Integer Whether it is a WeChat Mini Program playback: 1 for yes, 0 for no. Default is 0 [corresponds to the iswxa field in the API documentation]
extraParams false String Other custom parameters

Return Object Description

Parameter Name Type Description
token String Token (playback credential)
userId String User ID
videoId String Video ID, e.g., e6b23c6f519c5906e54a13b8200d7bb0_e
viewerIp String Viewer IP. If empty, the IP used to call the interface will be automatically obtained
viewerId String Viewer ID, different viewers must use different IDs
viewerName String Viewer name
extraParams String Other custom parameters
ttl Long Token validity period in milliseconds
createdTime Date Token creation time
expiredTime Date Token expiration time
isWxa Integer Whether it is a WeChat Mini Program playback: 1 for yes, 0 for no [corresponds to the iswxa field in the API documentation]
disposable Boolean Token validity: true means the token is valid only once (invalid after one verification), false means it can be verified multiple times within the validity period






4. Query Playback Domain Restriction Settings

Description

通过用户id查询播放域名限制设置
接口地址(仅做说明使用):https://api.polyv.net/v2/play/%s/domain

Call Constraints

  1. The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.

Unit Test

    @Test
    public void testGetPlayDomain() throws IOException, NoSuchAlgorithmException {
        VodGetPlayDomainRequest vodGetPlayDomainRequest = new VodGetPlayDomainRequest();
        VodGetPlayDomainResponse vodGetPlayDomainResponse = null;
        try {
            vodGetPlayDomainResponse = new VodPlayerSettingsServiceImpl().getPlayDomain(vodGetPlayDomainRequest);
            Assert.assertNotNull(vodGetPlayDomainResponse);
            if (vodGetPlayDomainResponse != null) {
                log.debug("测试查询播放域名限制设置成功,{}", JSON.toJSONString(vodGetPlayDomainResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a VodGetPlayDomainResponse object is returned, and the B-side processes business logic based on this object.

  2. If the request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failure field [pic cannot be empty / msg cannot be empty]].

  3. If the server processes abnormally, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

This method uses system-wide configuration and does not require explicit parameter passing.

Return Object Description

Parameter Name Type Description
userid String User ID
settingType Integer Restriction type: 0 for no domain restriction, 1 for blacklist, 2 for whitelist, 3 for combined whitelist and blacklist restriction
disableHost String Domains prohibited from playback (blacklist). Multiple domains are separated by commas. Valid when settingType = 1
enableHost String Domains allowed for playback (whitelist). Multiple domains are separated by commas. Valid when settingType = 2






5. Modify Playback Domain Restriction Settings

Description

通过域名修改播放域名限制设置
接口地址(仅做说明使用):https://api.polyv.net/v2/play/%s/domain

Call Constraints

  1. The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.

Unit Test

    @Test
    public void testUpdatePlayDomain() throws IOException, NoSuchAlgorithmException {
        VodUpdatePlayDomainRequest vodUpdatePlayDomainRequest = new VodUpdatePlayDomainRequest();
        Boolean vodUpdatePlayDomainResponse = null;
        try {
            vodUpdatePlayDomainRequest.setSettingType(1).setHost("www.baidu.com");
            vodUpdatePlayDomainResponse = new VodPlayerSettingsServiceImpl().updatePlayDomain(
                    vodUpdatePlayDomainRequest);
            Assert.assertTrue(vodUpdatePlayDomainResponse);
            if (vodUpdatePlayDomainResponse) {
                log.debug("测试修改播放域名限制设置成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-side processes business logic based on this object.

  2. If the request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Input parameter [xxx.chat.VodxxxRequest] object validation failed, failure field [pic cannot be empty / msg cannot be empty]].

  3. If the server processes abnormally, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), for example: [Error returned by Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
settingType true Integer Restriction type: 0 for no domain restriction, 1 for blacklist, 2 for whitelist, 3 for combined whitelist and blacklist restriction
host false String Domains prohibited from playback (blacklist). Multiple domains are separated by commas. Valid when settingType = 1

Return Object Description

null

联系客服,在线咨询