> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/live/java/channelold.md).

# Channel Old

## 描述

```
创建一个直播频道，返回直播频道相关的基础信息。
接口地址（仅做说明使用）：https://api.polyv.net/live/v2/channels/
```

## 调用约束

1、接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/live/java/limit.md)，调用常见异常，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/live/java/exceptionDoc/README.md)

## 单元测试

```java
	@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;
        }
    }
}
```

## 单元测试说明

1、请求正确，返回LiveChannelResponse对象，B端依据此对象处理业务逻辑；

2、请求参数校验不合格，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 输入参数 \[xxx.chat.LivexxxRequest]对象校验失败，失败字段 \[pic不能为空 / msg不能为空] ]

3、服务器处理异常，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 保利威请求返回数据错误，请求流水号：66e7ad29fd04425a84c2b2b562d2025b，错误原因： invalid signature. ]

## 请求入参描述

| 参数名               | 必选    | 类型      | 说明                                                                     |
| ----------------- | ----- | ------- | ---------------------------------------------------------------------- |
| name              | true  | String  | 自定义频道名称，一般是课程主题、会议主题、培训主题等，例如 财务制度培训、乌镇峰会                              |
| channelPasswd     | true  | String  | 自定义频道密码，B端讲师通过该密码进入直播间开播，长度不能超过16位,必须同时包含字母和数字                         |
| autoPlay          | false | Integer | 是否自动播放标识，0：关闭自动播放；1：开启，默认取值 1                                          |
| playerColor       | false | String  | 播放器控制栏颜色，默认：[#666666](https://www.colorgg.com/666666)                  |
| scene             | false | String  | 直播场景：alone 活动拍摄; ppt 三分屏; topclass 大班课; seminar 研讨会; 默认：alone          |
| categoryId        | false | Integer | 分类ID ,新建频道的所属分类，如果不提交，则为默认分类（分类ID可通过“获取直播分类”接口得到）                      |
| maxViewer         | false | Integer | 频道的最大在线人数观看限制的人数                                                       |
| watchLayout       | false | String  | 三分屏频道的观看布局，ppt：文档为主；video：视频为主；不设置会使用账号的通用设置                           |
| linkMicLimit      | false | Integer | 连麦人数，-1=<取值范围<=账号级的连麦人数，-1：表示使用账号默认的连麦人数，最大16人（注：账号级连麦人数需通知平台管理员设置才生效） |
| pureRtcEnabled    | false | String  | 是否为无延时直播，Y 表示开启，默认为N                                                   |
| receive           | false | String  | 是否为接收转播频道，Y表示是，不填或者填其他值为发起转播频道(注：需要开启频道转播功能该参数才生效)                     |
| receiveChannelIds | false | String  | 接收转播频道号，多个频道号用半角逗号,隔开，如果receive参数值为Y时，此参数无效(注：需要开启频道转播功能该参数才生效)        |

## 返回对象描述

| 参数名                 | 类型      | 说明                                                 |
| ------------------- | ------- | -------------------------------------------------- |
| channelId           | String  | 直播频道号                                              |
| userId              | String  | POLYV用户ID，和保利威官网一致，获取路径：官网->登录->直播（开发设置）           |
| name                | String  | 直播频道名称                                             |
| publisher           | String  | 主持人                                                |
| description         | String  | 直播频道描述                                             |
| url                 | String  | 直播推流地址                                             |
| stream              | String  | 直播流名称                                              |
| logoImage           | String  | 播放器logo                                            |
| logoOpacity         | Float   | Logo不透明度，1表示完全不透明                                  |
| logoPosition        | String  | <p>Logo位置<br>tr1：左上<br>tr：右上<br>b1：左下<br>br：右下</p> |
| logoHref            | String  | Logo的跳转链接                                          |
| coverImage          | String  | 播放前显示的封面图                                          |
| coverHref           | String  | 封面图的跳转链接                                           |
| waitImage           | String  | 等待推流时的显示图片                                         |
| waitHref            | String  | 等待推流时显示图片的跳转链接                                     |
| cutoffImage         | String  | 切断流时的显示图片                                          |
| cutoffHref          | String  | 切断流时显示图片的跳转链接                                      |
| advertType          | String  | 广告类型                                               |
| advertDuration      | Integer | 广告时长，单位：秒                                          |
| advertWidth         | Integer | 广告区域宽度                                             |
| advertHeight        | Integer | 广告区域高度                                             |
| advertImage         | String  | 图片广告                                               |
| advertHref          | String  | 广告的跳转链接                                            |
| advertFlvVid        | String  | 视频广告ID                                             |
| advertFlvUrl        | String  | 视频广告链接                                             |
| playerColor         | String  | 播放器控制栏颜色                                           |
| autoPlay            | Boolean | 自动播放，true为自动播放，false为关闭                            |
| warmUpFlv           | String  | 一开始的暖场视频                                           |
| passwdRestrict      | Boolean | 观看密码限制，需要输入观看密码才能播放流                               |
| passwdEncrypted     | String  | 观看密码加密后的密文                                         |
| isOnlyAudio         | String  | 仅推音频流，Y-是，N-否                                      |
| isLowLatency        | String  | 低延迟，Y-是，N-否                                        |
| m3u8Url             | String  | 直播拉流（播放）m3u8地址                                     |
| m3u8Url1            | String  | 直播拉流（播放）m3u8地址1                                    |
| m3u8Url2            | String  | 直播拉流（播放）m3u8地址2                                    |
| m3u8Url3            | String  | 直播拉流（播放）m3u8地址3                                    |
| currentTimeMillis   | Long    | 服务器返回的时间戳（毫秒）                                      |
| linkMicLimit        | Integer | 连麦人数                                               |
| channelLogoImage    | String  | 频道图标                                               |
| scene               | String  | 直播场景 alone：活动拍摄 ppt：三分屏 topclass：大班课 seminar：研讨会   |
| channelViewerPasswd | String  | 参与者密码                                              |
| channelPasswd       | String  | 频道密码                                               |
| streamType          | String  | 直播方式                                               |
| pureRtcEnabled      | String  | 是否是纯rtc拉流 Y：是 N：否                                  |
| type                | String  | 频道类型 发起转播：transmit 接收转播：receive 普通频道：normal        |
| cnAndEnLiveEnabled  | String  | 中英文直播间开关 Y：开启 N：关闭                                 |
| pushEnUrl           | String  | 英文推流地址                                             |

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/live/java/channelold.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.
