deprecatedChannelOperate
1. Create and Initialize a Channel
Description
创建并初始化频道
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/basic/create
Call Constraints
The API call is subject to rate limits. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
In
AuthSetting,AuthTypecannot directly set whitelist viewing. You need to create a channel first and then set the viewing conditions. ExampleIn AuthSetting, a maximum of two viewing conditions can be set (i.e., one primary viewing condition and one secondary viewing condition). The secondary condition only takes effect when the primary condition is present.
AuthSetting cannot set two AuthTypes that are identical.
Custom Authorization Integration Documentation, External Authorization Integration Documentation, Direct Authorization Integration Documentation
Unit Testing
@Test
public void testCreateChannelInit() throws Exception, NoSuchAlgorithmException {
LiveChannelInitRequest liveChannelInitRequest = new LiveChannelInitRequest();
LiveChannelInitResponse liveChannelInitResponse = null;
try {
LiveChannelInitRequest.BasicSetting basicSetting = new LiveChannelInitRequest.BasicSetting().setName(
"创建并初始化频道-验证码观看")
.setChannelPasswd(getRandomString(6))
.setAutoPlay(1)
.setPlayerColor("#666666")
.setScene(LiveConstant.SceneType.ALONE.getDesc())
.setCategoryId(340019)
.setMaxViewer(0)
.setStartTime(null)
.setDesc("这是一个描述")
.setPublisher("sadboy主讲")
.setLinkMicLimit(-1)
.setPureRtcEnabled("N")
.setReceiveChannelIds(null)
.setSubAccount("test-dev@qq.com")
.setOnlyOneLiveEnabled("N");
liveChannelInitRequest.setBasicSetting(basicSetting);
//验证码观看
LiveChannelInitRequest.AuthSetting codeAuthSettings = new LiveChannelInitRequest.AuthSetting().setRank(1)
.setAuthType(LiveConstant.AuthType.CODE.getDesc())
.setEnabled("Y")
.setAuthCode("123456")
.setQcodeTips("提示文案")
.setQcodeImg("https://live.polyv.net/static/images/live-header-logo.png");
//收费观看
LiveChannelInitRequest.AuthSetting moneyAuthSettings = new LiveChannelInitRequest.AuthSetting().setRank(2)
.setAuthType(LiveConstant.AuthType.PAY.getDesc())
.setEnabled("Y")
.setPayAuthTips("付费观看")
.setPrice(0.01f)
.setQcodeTips("提示文案")
.setQcodeImg("https://live.polyv.net/static/images/live-header-logo.png");
List<LiveChannelInitRequest.AuthSetting> authSettings = new ArrayList<LiveChannelInitRequest.AuthSetting>();
authSettings.add(codeAuthSettings);
authSettings.add(moneyAuthSettings);
liveChannelInitRequest.setAuthSettings(authSettings);
//回放设置
LiveChannelInitRequest.PlaybackSetting playbackSetting = new LiveChannelInitRequest.PlaybackSetting();
playbackSetting.setGlobalSettingEnabled("N").setPlaybackEnabled("Y").setType("single").setOrigin("record");
liveChannelInitRequest.setPlaybackSetting(playbackSetting);
//设置讲师
LiveChannelInitRequest.Teacher teacher = new LiveChannelInitRequest.Teacher();
teacher.setActor("讲师").setNickname("王老师");
liveChannelInitRequest.setTeacher(teacher);
//设置角色
LiveChannelInitRequest.Roles assistantRole = new LiveChannelInitRequest.Roles();
assistantRole.setNickname("孙助教").setActor("助教").setPasswd(getRandomString(6)).setRole("Assistant");
LiveChannelInitRequest.Roles guestRole = new LiveChannelInitRequest.Roles();
guestRole.setNickname("赵嘉宾").setActor("嘉宾").setPasswd(getRandomString(6)).setRole("Guest");
List<LiveChannelInitRequest.Roles> roles = new ArrayList<>();
roles.add(assistantRole);
roles.add(guestRole);
liveChannelInitRequest.setRoles(roles);
liveChannelInitResponse = new LiveChannelOperateServiceImpl().createChannelInit(liveChannelInitRequest);
Assert.assertNotNull(liveChannelInitResponse);
if (liveChannelInitResponse != null) {
//to do something ......
log.debug("测试创建并初始化频道 验证码观看创建成功{}", JSON.toJSONString(liveChannelInitResponse));
//TODO 此处创建完成后删除了频道,正式使用需删除该语句
deleteChannel(liveChannelInitResponse.getChannelId());
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, a LiveChannelInitResponse object is returned. The B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| basicSetting | true | BasicSetting | Basic settings see BasicSetting parameter description |
| authSettings | false | Array | Viewing condition settings see AuthSetting parameter description |
| playbackSetting | false | PlaybackSetting | Playback settings see PlaybackSetting parameter description |
| teacher | false | Teacher | Teacher settings see Teacher parameter description |
| roles | false | Array | Role settings see Roles parameter description |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain it by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
BasicSetting Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | String | Channel name |
| channelPasswd | false | String | Channel password, maximum length of 16 characters, must contain both letters and numbers |
| autoPlay | false | Integer | Whether to auto-play, 0 - do not auto-play; 1 - auto-play, default is 1 |
| playerColor | false | String | Player control bar color, default: #666666 |
| scene | false | String | Live streaming scene: alone (event shooting); ppt (three-screen); topclass (large class); seminar |
| categoryId | false | Integer | Category ID for the new channel. If not provided, the default category is used (category ID can be obtained via the "Get Live Categories" API) |
| maxViewer | false | Integer | Maximum number of concurrent online viewers |
| startTime | false | Date | Live streaming start time |
| desc | false | String | Content of the live streaming introduction |
| publisher | false | String | Host |
| linkMicLimit | false | Integer | Number of participants in co-streaming, -1 <= value range <= account-level co-streaming limit, -1: indicates using the account's default co-streaming limit, maximum 16 people (Note: The account-level co-streaming limit must be set by the platform administrator to take effect) |
| pureRtcEnabled | false | String | Whether it is a low-latency live stream, Y indicates enabled, default is N |
| receive | false | String | Whether it is a receiving relay channel, Y indicates yes. If left blank or filled with other values, it is a sending relay channel (Note: This parameter only takes effect if the channel relay function is enabled) |
| receiveChannelIds | false | String | Receiving relay channel IDs, multiple channel IDs separated by commas. If the receive parameter value is Y, this parameter is invalid (Note: This parameter only takes effect if the channel relay function is enabled) |
| onlyOneLiveEnabled | false | String | Whether the channel can only be streamed once, Y for yes, N for no, default is N |
| coverImg | false | String | Cover image URL |
| splashEnabled | false | String | Splash page toggle, default is N; Y: enabled, N: disabled |
| splashImg | false | String | Splash page image URL. Images not under the Polyv domain must first be uploaded via Upload Image Resource |
| likes | false | String | Number of likes |
| pageView | false | String | Cumulative number of views |
| closeBarrage | false | String | Whether to disable the barrage function, Y: disable, N: enable [Corresponds to the closeDanmu field in the API documentation] |
| showBarrageInfoEnabled | false | String | Whether to display barrage information toggle, Y: display, N: do not display [Corresponds to the showDanmuInfoEnabled field in the API documentation] |
| subAccount | false | String | Sub-account email. When filled, the channel will be created under this sub-account (the sub-account cannot be deleted or disabled). Currently, it cannot be obtained via the API |
AuthSetting Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| rank | true | Integer | General parameter: 1 for primary viewing condition, 2 for secondary viewing condition |
| enabled | true | String | General parameter: Whether enabled, Y for enabled, N for disabled |
| authType | false | String | General parameter: Pay to view - pay, verification code to view - code, whitelist to view - phone, registration to view - info, custom authorization to view - custom, external authorization - external, direct authorization (independent authorization) - direct |
| payAuthTips | false | String | Pay to view parameter: Welcome title, required when pay to view is selected |
| price | false | Float | Pay to view parameter: Price, in yuan, required when pay to view is selected |
| watchEndTime | false | Date | Pay to view parameter: Paid validity end date. Only one of watchEndTime and validTimePeriod can be set. When both watchEndTime and validTimePeriod are empty, it means the payment is valid permanently |
| validTimePeriod | false | Integer | Pay to view parameter: Paid validity duration, in days. When both watchEndTime and validTimePeriod are empty, it means the payment is valid permanently |
| authCode | false | String | Verification code to view parameter: Verification code, required when verification code to view is selected |
| qcodeTips | false | String | Verification code to view parameter: Prompt text |
| qcodeImg | false | String | Verification code to view parameter: QR code URL of the official account |
| authTips | false | String | Whitelist to view parameter: Prompt text |
| infoFields | false | Array | Registration to view parameter, required when registration to view is selected [See InfoField Parameter Description for details] |
| externalKey | false | String | External authorization parameter: SecretKey, required when external authorization is selected |
| externalUri | false | String | External authorization parameter: Custom URL, required when external authorization is selected |
| externalRedirectUri | false | String | External authorization parameter: Redirect URL |
| customKey | false | String | Custom authorization parameter: SecretKey, required when custom authorization is selected |
| customUri | false | String | Custom authorization parameter: Custom URL, required when custom authorization is selected |
| directKey | false | String | Direct authorization parameter: SecretKey used for direct authorization signing |
PlaybackSetting Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| globalSettingEnabled | false | String | Whether to apply global settings: Y: Yes; N: No; |
| playbackEnabled | false | String | Playback switch: Y: On; N: Off; |
| type | false | String | Playback mode: single: Single playback; list: List playback; |
| origin | false | String | Playback source: record: Temporary storage; playback: Playback list; vod: VOD list; |
| videoId | false | String | Video ID for single playback |
Teacher Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| nickname | false | String | Instructor nickname |
| actor | false | String | Instructor title |
| passwd | false | String | Instructor password (same as basicSetting.channelPasswd, can be omitted here) |
| avatar | false | String | Avatar image URL |
Roles Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| nickname | false | String | Character nickname |
| actor | false | String | Character title |
| passwd | false | String | Character password |
| avatar | false | String | Avatar image URL |
| role | false | String | Character type: Assistant: Teaching Assistant; Guest: Guest; |
InfoField Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | false | String | Registration info name, up to 8 characters |
| type | true | String | Registration type: name - name, text - text, mobile - mobile number, number - number, option - dropdown option. This field is required when registering for viewing. |
| options | false | String | For dropdown options, the option values separated by commas. Maximum of 8 options; each option content up to 8 characters |
| placeholder | false | String | Text input placeholder, up to 8 characters |
| sms | false | String | SMS verification toggle: Y for enabled, N for disabled |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Live channel ID |
| userId | String | POLYV user ID, consistent with the official POLYV website. Retrieval path: Official website -> Login -> Live (Development Settings) |
| name | String | Live channel name |
| publisher | String | Host |
| description | String | Live channel description |
| url | String | Live streaming push URL |
| stream | String | Live stream name |
| logoImage | String | Player logo |
| logoOpacity | Float | Logo opacity, 1 means fully opaque |
| logoPosition | String | Logo position tr1: Top left tr: Top right b1: Bottom left br: Bottom right |
| logoHref | String | Logo click-through link |
| coverImage | String | Cover image displayed before playback |
| coverHref | String | Cover image click-through link |
| waitImage | String | Image displayed while waiting for stream push |
| waitHref | String | Click-through link for the image displayed while waiting for stream push |
| cutoffImage | String | Image displayed when stream is cut off |
| cutoffHref | String | Click-through link for the image displayed when stream is cut off |
| advertType | String | Ad type |
| advertDuration | String | Ad duration, in seconds |
| advertWidth | String | Ad area width |
| advertHeight | String | Ad area height |
| advertImage | String | Image ad |
| advertHref | String | Ad click-through link |
| advertFlvVid | String | Video ad ID |
| advertFlvUrl | String | Video ad URL |
| playerColor | String | Player control bar color |
| autoPlay | Boolean | Auto-play |
| warmUpFlv | String | Initial warm-up video |
| passwdRestrict | Boolean | Viewing password restriction, requires entering a viewing password to play the stream |
| passwdEncrypted | String | Encrypted viewing password ciphertext |
| isOnlyAudio | String | Audio-only stream: Y: Audio mode; N: Normal mode; |
| isLowLatency | String | Low latency, Y - Low latency, N - Non-low latency |
| m3u8Url | String | Live stream pull (playback) m3u8 URL |
| m3u8Url1 | String | Live stream pull (playback) m3u8 URL 1 |
| m3u8Url2 | String | Live stream pull (playback) m3u8 URL 2 |
| m3u8Url3 | String | Live stream pull (playback) m3u8 URL 3 |
| channelLogoImage | String | Channel icon |
| scene | String | Live scene alone: Event recording ppt: Three-screen split topclass: Large class seminar: Seminar |
| channelViewerPasswd | String | Participant password |
| channelPasswd | String | Channel password |
| linkMicLimit | Integer | Number of mic connections -1: Use account mic connection score 0-16: Represents number of mic connections |
| streamType | String | Live streaming method client: Client push pull: Pull stream thirdpull: Third-party pull stream disk: Hard disk push audio: Audio live streaming |
| pureRtcEnabled | String | Whether it is a zero-latency live stream, default is N Y: Yes N: No |
| type | String | Channel type Transmit: Relay broadcast receive: Receive relay broadcast normal: Normal channel |
| cnAndEnLiveEnabled | String | Chinese and English live room switch Y: Enabled N: Disabled |
| pushEnUrl | String | English push URL |
| currentTimeMillis | Long | Server-returned timestamp (milliseconds) |
2. Query Basic Channel Information
Description
查询频道基本信息
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/basic/get
Call Constraints
- The API call has a frequency limit. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testGetChannelBasicInfo() throws Exception, NoSuchAlgorithmException {
LiveChannelBasicInfoRequest liveChannelBasicInfoRequest = new LiveChannelBasicInfoRequest();
LiveChannelBasicInfoResponse liveChannelBasicInfoResponse;
try {
//准备测试数据
String channelId = super.createChannel();
liveChannelBasicInfoRequest.setChannelId(channelId);
liveChannelBasicInfoResponse = new LiveChannelOperateServiceImpl().getChannelBasicInfo(
liveChannelBasicInfoRequest);
Assert.assertNotNull(liveChannelBasicInfoResponse);
if (liveChannelBasicInfoResponse != null) {
//to do something ......
log.debug("查询频道基本信息成功{}", JSON.toJSONString(liveChannelBasicInfoResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Description
If the request is correct, a
LiveChannelBasicInfoResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. SeePloyvSdkException.getMessage()for error details, e.g., [ Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. This parameter is required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| name | String | Channel name |
| scene | String | Live streaming scenario: alone (event filming); ppt (three-screen split); topclass (large class); seminar (seminar) |
| newScene | String | New backend live streaming scenario; if undefined, use sceneundefined: Not defined topclass: Large class double: Dual-teacher class (requires permission) train: Enterprise training seminar: Seminar alone: Event marketing |
| template | String | New backend live streaming template; if it is an old version channel, this field is undefined undefined: Not defined ppt: Document + video alone: Pure video (professional) topclass: Pure video (fast) seminar: Seminar portrait_ppt: Document + video (portrait) portrait_alone: Video (portrait) |
| channelPasswd | String | Channel password |
| pureRtcEnabled | String | Low-latency switch Y: Enabled N: Disabled |
| publisher | String | Host name |
| startTime | Date | Live streaming start time; null when closed |
| pageView | Integer | Cumulative page views |
| likes | Integer | Number of likes on the viewing page |
| coverImg | String | Channel icon URL |
| splashImg | String | Splash page image URL |
| splashEnabled | String | Splash page switch (value: Y/N) |
| desc | String | Live streaming description |
| consultingMenuEnabled | String | Consultation and Q&A switch (value: Y/N) |
| maxViewerRestrict | String | Maximum online viewer limit switch (value: Y/N) |
| maxViewer | Integer | Maximum number of online viewers |
| watchStatus | String | Viewing page status of the channel; values: live (streaming), end (streaming ended), playback (playback in progress), waiting (waiting for streaming) |
| watchStatusText | String | Viewing page status description: streaming, playback in progress, ended, not started |
| userCategory | UserCategory | Information on the category to which the channel belongs See UserCategory parameter description |
| authSettings | Array | List of live streaming viewing conditions See AuthSetting parameter description |
UserCategory Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| categoryId | Integer | Category ID |
| categoryName | String | Category name |
| userId | String | POLYV user ID, consistent with the one on the Polyv official website. Retrieval path: Official website -> Login -> Live Streaming (Development Settings) |
| rank | Integer | Sort value of the category |
AuthSetting Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| userId | String | POLYV user ID, consistent with the one on the Polyv official website. Retrieval path: Official website -> Login -> Live Streaming (Development Settings) |
| rank | Integer | Used to set two viewing conditions for one channel, value is 1 or 2 (1 for primary condition, 2 for secondary condition) |
| globalSettingEnabled | String | Whether to enable global settings (Y/N) |
| enabled | String | Whether to enable viewing conditions (Y/N) |
| authType | String | Viewing condition type (1. No restriction none 2. Verification code code 3. Paid viewing pay 4. Whitelist viewing phone 5. Registration viewing info 6. Share viewing wxshare 7. Custom authorization custom 8. External authorization external) |
| authTips | String | Prompt message for whitelist viewing |
| payAuthTips | String | Prompt message for paid viewing |
| authCode | String | Verification code for the verification code viewing method |
| qcodeTips | String | QR code prompt for the verification code viewing method |
| qcodeImg | String | QR code image for the verification code viewing method |
| price | Float | Price for paid viewing |
| watchEndTime | Date | Deadline for paid viewing; null means one-time payment, valid forever |
| validTimePeriod | Integer | Validity duration for paid viewing (in days) |
| customKey | String | Key for custom authorization viewing |
| customUri | String | API endpoint for custom authorization viewing |
| externalKey | String | Key for external authorization viewing |
| externalUri | String | API endpoint for external authorization viewing |
| externalRedirectUri | String | Redirect URL for external authorization viewing when users directly access the viewing page |
3. Batch Create Channels
Description
批量创建频道
接口地址(仅做说明使用):https://api.polyv.net/live/v3/channel/basic/batch-create
Call Constraints
- The API call has a frequency limit. Click here for details. For common call exceptions, click here for details.
Unit Testing
@Test
public void testCreateChannelList() throws Exception, NoSuchAlgorithmException {
LiveCreateChannelListRequest liveCreateChannelListRequest = new LiveCreateChannelListRequest();
LiveCreateChannelListResponse liveCreateChannelListResponse;
try {
List<LiveCreateChannelListRequest.LiveChannelBasic> channels =
new ArrayList<LiveCreateChannelListRequest.LiveChannelBasic>();
for (int i = 0; i <= 2; i++) {
LiveCreateChannelListRequest.LiveChannelBasic liveChannel =
new LiveCreateChannelListRequest.LiveChannelBasic();
liveChannel.setName("批量创建" + i)
.setChannelPasswd("123456" + i)
.setCourseId("c" + i)
.setAutoPlay(1)
.setPlayerColor("#666666")
.setScene(LiveConstant.SceneType.ALONE.getDesc())
.setSubAccount("test-dev@qq.com")
.setCategoryId(340019);
channels.add(liveChannel);
}
liveCreateChannelListRequest.setChannels(channels);
liveCreateChannelListResponse = new LiveChannelOperateServiceImpl().createChannelList(
liveCreateChannelListRequest);
Assert.assertNotNull(liveCreateChannelListResponse);
if (liveCreateChannelListResponse != null) {
//to do something ......
log.debug("频道批量创建成功{}", JSON.toJSONString(liveCreateChannelListResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Description
If the request is correct, a
LiveCreateChannelListResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed fields: [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channels | true | Array | Channel list See LiveChannelBasic parameter description |
| appId | false | String | POLYV user APP_ID, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account calls). Obtained by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required when calling with multiple accounts (i.e., when initMultiAccount() has been called to set up multi-account calls). Obtained by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
LiveChannelBasic Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | true | String | Channel name |
| channelPasswd | false | String | Channel password, must not exceed 16 characters and must contain both letters and numbers |
| courseId | false | String | Course ID |
| autoPlay | false | Integer | Whether to auto-play, 0/1, default is 1. Note: If this value is empty, the channel will use the global "feature switch settings". If not empty, the channel's own "feature switch settings" will be used. |
| playerColor | false | String | Player control bar color, default: #666666 |
| scene | false | String | Live streaming scene: alone (event recording); ppt (three-screen); topclass (large class); seminar (seminar) |
| categoryId | false | Integer | Category ID for the new channel. If not submitted, the default category will be used. Category IDs can be obtained via the "Get Live Categories" API. |
| subAccount | false | String | Sub-account email. If filled, the channel will be created under this sub-account (the sub-account cannot be deleted or disabled). Currently, it cannot be retrieved via API. |
Return Object Description
| Parameter Name | Type | Description |
|---|---|---|
| channels | Array | Basic channel information [See LiveChannelResponse Parameter Description] |
LiveChannelResponse Parameter Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Live channel ID |
| userId | String | POLYV user ID, consistent with the official Polyv website. Retrieval path: Official website -> Login -> Live (Development Settings) |
| name | String | Live channel name |
| publisher | String | Host |
| description | String | Live channel description |
| url | String | Live streaming push URL |
| stream | String | Live stream name |
| logoImage | String | Player logo |
| logoOpacity | Float | Logo opacity, 1 means fully opaque |
| logoPosition | String | Logo position tr1: Top left tr: Top right b1: Bottom left br: Bottom right |
| logoHref | String | Logo click-through link |
| coverImage | String | Cover image displayed before playback |
| coverHref | String | Cover image click-through link |
| waitImage | String | Image displayed while waiting for stream push |
| waitHref | String | Click-through link for the image displayed while waiting for stream push |
| cutoffImage | String | Image displayed when stream is cut off |
| cutoffHref | String | Click-through link for the image displayed when stream is cut off |
| advertType | String | Ad type |
| advertDuration | Integer | Ad duration, in seconds |
| advertWidth | Integer | Ad area width |
| advertHeight | Integer | Ad area height |
| advertImage | String | Image ad |
| advertHref | String | Ad click-through link |
| advertFlvVid | String | Video ad ID |
| advertFlvUrl | String | Video ad URL |
| playerColor | String | Player control bar color |
| autoPlay | Boolean | Auto-play, true for auto-play, false to disable |
| warmUpFlv | String | Initial warm-up video |
| passwdRestrict | Boolean | Viewing password restriction, requires entering a viewing password to play the stream |
| passwdEncrypted | String | Encrypted ciphertext of the viewing password |
| isOnlyAudio | String | Audio-only stream push, Y-Yes, N-No |
| isLowLatency | String | Low latency, Y-Yes, N-No |
| m3u8Url | String | Live stream pull (playback) m3u8 URL |
| m3u8Url1 | String | Live stream pull (playback) m3u8 URL 1 |
| m3u8Url2 | String | Live stream pull (playback) m3u8 URL 2 |
| m3u8Url3 | String | Live stream pull (playback) m3u8 URL 3 |
| currentTimeMillis | Long | Server-returned timestamp (milliseconds) |
| linkMicLimit | Integer | Number of participants allowed for mic connection |
| channelLogoImage | String | Channel icon |
| scene | String | Live scene alone: Event shooting ppt: Three-screen topclass: Large class seminar: Seminar |
| channelViewerPasswd | String | Participant password |
| channelPasswd | String | Channel password |
| streamType | String | Live streaming method |
| pureRtcEnabled | String | Whether it is pure RTC stream pulling Y: Yes N: No |
| type | String | Channel type Initiate relay: transmit Receive relay: receive Normal channel: normal |
| cnAndEnLiveEnabled | String | Chinese and English live room switch Y: Enabled N: Disabled |
| pushEnUrl | String | English push URL |
4. Create Role - Teaching Assistant
Description
创建角色-助教
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channelAccount/%s/add
Call Constraints
- The API call has a frequency limit. For details, see [/live/java/limit.md]. For common call exceptions, see [/live/java/exceptionDoc].
Unit Testing
@Test
public void testCreateSonChannelAssistant() throws Exception, NoSuchAlgorithmException {
LiveCreateSonChannelRequest liveCreateSonChannelRequest = new LiveCreateSonChannelRequest();
LiveCreateSonChannelResponse liveCreateSonChannelResponse;
try {
//准备测试数据
String channelId = super.createChannel();
List<String> sonChannelIds = getDelSonChannelIds();
for (String temp : sonChannelIds) {
deleteSonChannel(temp);
}
liveCreateSonChannelRequest.setChannelId(channelId)
.setRole(null)
.setNickname("sadboy")
.setActor("教授")
.setAvatar("https://www.polyv.net/assets/dist/images/web3.0/c-header/hd-logo.svg?v=2.0");
liveCreateSonChannelResponse = new LiveChannelOperateServiceImpl().createSonChannel(
liveCreateSonChannelRequest);
Assert.assertNotNull(liveCreateSonChannelResponse);
if (liveCreateSonChannelResponse != null) {
//to do something ......
log.debug("创建角色成功{}", JSON.toJSONString(liveCreateSonChannelResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, a
LiveCreateSonChannelResponseobject is returned, and the B-side processes business logic based on this object.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| role | false | String | Default is not passed as assistant; pass "Guest" for guest role |
| nickname | false | String | Nickname of the created assistant or guest |
| actor | false | String | Title of the created assistant or guest |
| avatar | false | String | Avatar of the created assistant or guest |
| appId | false | String | POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account invocation). Obtain it by registering on the POLYV official website: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| account | String | Assistant ID |
| userId | String | POLYV user ID, consistent with the official POLYV website. Retrieval path: Official website -> Login -> Live Streaming (Development Settings) |
| channelId | String | Channel ID |
| passwd | String | Assistant password |
| nickname | String | Assistant name |
| stream | String | Assistant stream name (invalid when used alone) |
| status | String | Assistant status (Y/N) |
| createdTime | Date | Time the assistant was created |
| lastModified | Date | Last modification time of the assistant |
| sort | Integer | Sequence number of the assistant among all assistants in the channel |
| avatar | String | Assistant avatar |
| pageTurnEnabled | String | Assistant page turning permission (only one assistant can have it, Y or N) |
| notifyEnabled | String | Permission to publish announcements (Y/N) |
| checkinEnabled | String | Permission to enable check-in (Y/N) |
| voteEnabled | String | Permission to initiate voting (Y/N) |
| role | String | Role assistant: Assistant guest: Guest |
5. Setting Roles
Description
设置角色
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channelAccount/%s/update
Call Constraints
- The API call has a frequency limit. For details, please refer to [/live/java/limit.md]. For common call exceptions, please refer to [/live/java/exceptionDoc].
Unit Testing
@Test
public void testUpdateSonChannelInfo() throws Exception, NoSuchAlgorithmException {
LiveUpdateSonChannelInfoRequest liveUpdateSonChannelInfoRequest = new LiveUpdateSonChannelInfoRequest();
Boolean liveUpdateSonChannelInfoResponse;
try {
//准备测试数据
String channelId = super.createChannel();
String sonChannelId = createSonChannel(channelId);
liveUpdateSonChannelInfoRequest.setChannelId(channelId)
.setAccount(sonChannelId)
.setNickname("sadboy")
.setPassword(getRandomString(16))
.setAvatar("https://www.polyv.net/assets/dist/images/web3.0/c-header/hd-logo.svg?v=2.0")
.setActor("教授")
.setPageTurnEnabled("Y")
.setNotifyEnabled("Y");
liveUpdateSonChannelInfoResponse = new LiveChannelOperateServiceImpl().updateSonChannelInfo(
liveUpdateSonChannelInfoRequest);
Assert.assertNotNull(liveUpdateSonChannelInfoResponse);
if (liveUpdateSonChannelInfoResponse) {
//to do something ......
log.debug("设置角色信息成功");
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
Unit Testing Instructions
If the request is correct, a Boolean object is returned, and the B-side processes business logic based on this object.
If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found inPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, see PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| account | true | String | Teaching assistant/guest account |
| nickname | false | String | Nickname |
| password | false | String | Role password |
| avatar | false | String | Avatar |
| actor | false | String | Role title |
| pageTurnEnabled | false | String | Teaching assistant page turning permission, value is Y or N, Y for enabled, N for disabled |
| notifyEnabled | false | String | Role announcement permission, value is Y or N, Y for enabled, N for disabled |
| appId | false | String | POLYV user APP_ID, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET, required for multi-account calls (i.e., when initMultiAccount() is called to set up multi-account calls). Obtain by registering on the POLYV official website. Path: Official website -> Login -> Live Streaming (Development Settings) |
Return Object Description
true indicates success, false indicates failure
6. Get Instructor Information
Description
获取讲师信息
接口地址(仅做说明使用):https://api.polyv.net/live//v3/channel/account/getTeacher
Call Constraints
- The API call has a frequency limit. See details. For common call exceptions, see details.
Unit Testing
@Test
public void testChannelGetTeacher() throws Exception, NoSuchAlgorithmException {
LiveChannelGetTeacherRequest liveChannelGetTeacherRequest = new LiveChannelGetTeacherRequest();
LiveChannelGetTeacherResponse liveChannelGetTeacherResponse;
try {
//准备测试数据
String channelId = super.createChannel();
liveChannelGetTeacherRequest.setChannelId(channelId);
liveChannelGetTeacherResponse = new LiveChannelOperateServiceImpl().getTeacher(liveChannelGetTeacherRequest);
Assert.assertNotNull(liveChannelGetTeacherResponse);
if (liveChannelGetTeacherResponse != null) {
//to do something ......
log.debug("获取讲师信息成功: %s",JSON.toJSONString(liveChannelGetTeacherResponse));
}
} catch (PloyvSdkException e) {
//参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
log.error(e.getMessage(), e);
// 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
throw e;
} catch (Exception e) {
log.error("SDK调用异常", e);
throw e;
}
}
}
Unit Testing Instructions
If the request is correct, return a
LiveChannelGetTeacherResponseobject, based on which the B-side handles business logic.If request parameter validation fails, a
PloyvSdkExceptionis thrown. The error message can be found viaPloyvSdkException.getMessage(), for example: [ Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]The server encountered an exception and threw a PloyvSdkException. For error details, refer to PloyvSdkException.getMessage(), e.g., [ Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| channelId | true | String | Channel ID |
| appId | false | String | POLYV user APP_ID. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official Website -> Login -> Live Streaming (Development Settings) |
| appSecret | false | String | POLYV user APP_SECRET. This parameter is required for multi-account calls (i.e., when initMultiAccount() has been called to set up multi-account invocation). Obtain it by registering on the POLYV official website. Path: Official Website -> Login -> Live Streaming (Development Settings) |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| account | String | Instructor ID, same as channel number |
| actor | String | Instructor title |
| avatar | String | Instructor avatar, e.g., //liveimages.videocc.net/uploaded/images/2023/04/gjps9etdpx.jpg |
| channelId | String | Channel number |
| nickname | String | Instructor nickname |
| passwd | String | Instructor login password |
| loginCode | String | This field is null |
| role | String | This field is null |
