channelOld
Updated: 2025-09-11 15:18:09
1. Create Channel
Description
创建一个直播频道,返回直播频道相关的基础信息。
接口地址(仅做说明使用):https://api.polyv.net/live/v2/channels/
Call Constraints
- API calls are subject to rate limits. Click here for details. For common call exceptions, click here.
Unit Test
@Test
public void testCreateChannel() throws Exception, NoSuchAlgorithmException {
LiveChannelRequest liveChannelRequest = new LiveChannelRequest();
LiveChannelResponse liveChannelResponse = null;
try {
liveChannelRequest.setName("Spring 知识精讲").setChannelPasswd("666888");
// .setAutoPlay(LiveConstant.AutoPlay.AOTU_PLAY.getFlag())
// .setScene(LiveConstant.SceneType.PPT.getDesc())
// .setMaxViewer(300)
// .setWatchLayout(LiveConstant.WatchLayout.PPT.getFlag())
// .setLinkMicLimit(2)
// .setPureRtcEnabled(LiveConstant.Flag.YES.getFlag())
// .setReceive(LiveConstant.Flag.YES.getFlag())
liveChannelResponse = new LiveChannelOperateServiceImpl().createChannel(liveChannelRequest);
Assert.assertNotNull(liveChannelResponse);
if (liveChannelResponse != null) {
//to do something ......
log.debug("频道创建成功{}", JSON.toJSONString(liveChannelResponse));
log.debug("网页开播地址:https://live.polyv.net/web-start/login?channelId={} , 登录密码: {}",
liveChannelResponse.getChannelId(), liveChannelRequest.getChannelPasswd());
log.debug("网页观看地址:https://live.polyv.cn/watch/{} ", liveChannelResponse.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 Test Description
If the request is correct, a LiveChannelResponse object is returned, and the B-end processes business logic based on this object.
If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed. Failed fields: [pic cannot be empty / msg cannot be empty]].
If the server encounters an exception, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request data. Request serial number: 66e7ad29fd04425a84c2b2b562d2025b. Error reason: invalid signature.]
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| userId | false | String | POLYV user ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain it by registering on the Polyv official website. Path: Official website -> Login -> Live (Development Settings). |
| name | true | String | Custom channel name, typically the course topic, meeting topic, training topic, etc. For example, Financial System Training, Wuzhen Summit. |
| channelPasswd | true | String | Custom channel password. The B-end instructor uses this password to enter the live room and start broadcasting. Length cannot exceed 16 characters and must contain both letters and numbers. |
| autoPlay | false | Integer | Auto-play flag. 0: Disable auto-play; 1: Enable. Default value is 1. |
| 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). Default: alone. |
| categoryId | false | Integer | Category ID. The category to which the new channel belongs. If not submitted, the default category is used. (Category ID can be obtained via the "Get Live Categories" API.) |
| maxViewer | false | Integer | Maximum number of concurrent viewers allowed for the channel. |
| watchLayout | false | String | Viewing layout for three-screen channels. ppt: Document-focused; video: Video-focused. If not set, the account's general settings are used. |
| linkMicLimit | false | Integer | Number of participants allowed in the mic. Range: -1 <= value <= account-level mic limit. -1: Use the account's default mic limit. Maximum 16 participants. (Note: The account-level mic limit must be set by the platform administrator to take effect.) |
| pureRtcEnabled | false | String | Whether to enable low-latency live streaming. Y: Enable; N: Disable. Default is N. |
| receive | false | String | Whether it is a receiving relay channel. Y: Yes. If left blank or set to another value, it is an initiating relay channel. (Note: The channel relay feature must be enabled for this parameter to take effect.) |
| receiveChannelIds | false | String | Receiving relay channel IDs. Multiple channel IDs should be separated by commas. If the receive parameter value is Y, this parameter is invalid. (Note: The channel relay feature must be enabled for this parameter to take effect.) |
| appId | false | String | POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain it by registering on the Polyv official website. Path: Official website -> Login -> Live (Development Settings). |
| appSecret | false | String | POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain it by registering on the Polyv official website. Path: Official website -> Login -> Live (Development Settings). |
Return Object Description
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Live channel ID. |
| userId | String | POLYV user ID, consistent with the Polyv official website. 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 indicates 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 waiting image. |
| cutoffImage | String | Image displayed when the stream is cut off. |
| cutoffHref | String | Click-through link for the cutoff image. |
| 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: Enable; false: Disable. |
| warmUpFlv | String | Initial warm-up video. |
| passwdRestrict | Boolean | Viewing password restriction. A password is required to play the stream. |
| passwdEncrypted | String | Encrypted 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 return timestamp (milliseconds). |
| linkMicLimit | Integer | Number of participants allowed in the mic. |
| channelLogoImage | String | Channel icon. |
| scene | String | Live streaming scene. alone: Event Recording; ppt: Three-Screen; topclass: Large Class; seminar: Seminar. |
| channelViewerPasswd | String | Participant password. |
| channelPasswd | String | Channel password. |
| streamType | String | Live streaming method. |
| pureRtcEnabled | String | Whether to use pure RTC for stream pulling. Y: Yes; N: No. |
| type | String | Channel type. Initiating relay: transmit; Receiving relay: receive; Normal channel: normal. |
| cnAndEnLiveEnabled | String | Chinese and English live room switch. Y: Enable; N: Disable. |
| pushEnUrl | String | English push URL. |
