Commit a297694d5053f1838131560b300960c6a4e4207e

Authored by 刘炯
1 parent c98c13b7

直播活动信息接口

02.直播云/1.1 获取直播活动信息接口.md renamed to 02.直播云/1.0 获取直播活动信息接口Server.md
02.直播云/1.1 获取直播活动信息接口APP.md 0 → 100644
  1 +/*
  2 +Title: 1.1 获取某直播活动信息接口 for APP_SDK or WebServer
  3 +*/
  4 +
  5 +### 接口描述 ###
  6 +
  7 +
  8 +### 接口地址 ###
  9 +http://api.cnlive.com/open/api2/live_zbsc/getLiveActivityPlayInfo
  10 +
  11 +### 接口协议 ###
  12 +HTTP GET
  13 +
  14 +### 接口请求参数 ###
  15 +| 参数名 | 参数类型 | 必选 | 参数说明 |
  16 +| :----------- | :------: | :------: | :------: |
  17 +| appId | string | true | 应用ID |
  18 +| activityId| string | true | 由开发者通过API创建接口或者在直播云管理端创建,保证唯一性 |
  19 +| timestamp | int | true | 精确到秒,当前Unix时间戳,请保证请求服务器时间正确 |
  20 +| sign | String | true | 签名规则见 [签名详情] (http://help.open.cnlive.com/common.html) |
  21 +
  22 +
  23 +### 返回值 ###
  24 +
  25 +| 参数名 | 参数类型 | 必选 | 参数说明 |
  26 +| :----------- | :------: | :------: | :------: |
  27 +| errorCode | int | true | 错误类型号 |
  28 +| message| string | true | 错误类型 |
  29 +| activityid| string | true | 活动ID,确保SP下的唯一性 |
  30 +| activityname | string | true | 活动名称 |
  31 +| activitystatus | int | true | 活动状态,0:未开始 /1:已开始 /3:已结束 /4 已下线,默认为0 |
  32 +| isHorizontalScreen | int | true | 屏幕方向,0:垂直即竖屏 /1:水平即横屏 ,默认为1 |
  33 +| channelID | string | true | 播放通道;PGC业务:平台分配/ UGC业务:主播ID生成,确保SP下的唯一性 |
  34 +| createTime | string | false | 开始时间,格式yyyyMMddHHmmss |
  35 +| startTime | string | false | 开始时间,格式yyyyMMddHHmmss |
  36 +| endTime | string | false | 开始时间,格式yyyyMMddHHmmss |
  37 +| coverImgUrl | string | false | 活动封面 |
  38 +| activityCategory | string | false | 活动分类ID,001 发布会/002 婚礼/003 年会 /004 体育/005 游戏/006 旅游&户外/007 财经/008 演唱会/009 烹饪/010 宠物&动物/011 访谈/012 教育/013 竞技/014 剧场/015 晚会/016 电视节目/017 秀场 |
  39 +| extensions | string | false | 扩展字段,参数格式为Map对象的Json字符串 (主播昵称、头像等等) |
  40 +| mp4_url_rate1 | string | false |流畅版的rtmp播放地址 |
  41 +| mp4_url_rate2 | string | true | 标清版的rtmp播放地址,必须有|
  42 +| mp4_url_rate3 | string | false | 高清版的rtmp播放地址 |
  43 +| mp4_url_rate4 | string | false | 超清版的rtmp播放地址 |
  44 +| hls_url_rate1 | string | false |流畅版的m3u8播放地址 |
  45 +| hls_url_rate2 | string | true | 标清版的m3u8播放地址,必须有|
  46 +| hls_url_rate3 | string | false | 高清版的m3u8播放地址 |
  47 +| hls_url_rate4 | string | false | 超清版的m3u8播放地址 |
  48 +| extViews | 对象数组 | false | 扩展机位的播放信息(不含主画面PGM的播放信息) |
  49 +
  50 +返回JSON格式的节目元数据信息,json示例如下:
  51 +
  52 +``` json
  53 +{
  54 + "errorCode":"0",
  55 + "messagae":"请求成功",
  56 + "data"{
  57 + "activityid":"xxxxx",
  58 + "activitystatus":"1",
  59 + "activityname":"测试活动",
  60 + "coverImgUrl":"小图图片URL",
  61 + "isHorizontalScreen":"1",
  62 + "channelID":"xinyingshi",
  63 + "startTime":"",
  64 + "endTime":"",
  65 + "createTime":"",
  66 + "extensions":"",
  67 + "activityCategory":"",
  68 + "mp4_url_rate1":"",
  69 + "mp4_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi&rate=2&sp_id=iqhpk8pl19",
  70 + "mp4_url_rate3":"",
  71 + "mp4_url_rate4":"",
  72 + "hls_url_rate1":"",
  73 + "hls_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplay?channelID=xinyingshi&rate=2&sp_id=iqhpk8pl19",
  74 + "hls_url_rate3":"",
  75 + "hls_url_rate4":"",
  76 + "extViews"[
  77 + {
  78 + "mp4_url_rate1":"",
  79 + "mp4_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi_m1&rate=2&sp_id=iqhpk8pl19",
  80 + "mp4_url_rate3":"",
  81 + "mp4_url_rate4":"",
  82 + "hls_url_rate1":"",
  83 + "hls_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplay?channelID=xinyingshi_m1&rate=2&sp_id=iqhpk8pl19",
  84 + "hls_url_rate3":"",
  85 + "hls_url_rate4":""
  86 + },
  87 + {
  88 + "mp4_url_rate1":"",
  89 + "mp4_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi_m2&rate=2&sp_id=iqhpk8pl19",
  90 + "mp4_url_rate3":"",
  91 + "mp4_url_rate4":"",
  92 + "hls_url_rate1":"",
  93 + "hls_url_rate2":"http://api.cnlive.com/open/api3/play/IPS/liveplay?channelID=xinyingshi_m2&rate=2&sp_id=iqhpk8pl19",
  94 + "hls_url_rate3":"",
  95 + "hls_url_rate4":""
  96 + }
  97 + ]
  98 + }
  99 +}
  100 +```
  101 +
  102 +
  103 +
  104 +``` java
  105 +public String getPlayInfo() {
  106 + String result = "";
  107 + Map params = new HashMap<>();
  108 + params.put("sp_id", "iqhpk8pl19");
  109 + params.put("customID", "d849bb4277be42799df3ffc21654d949");
  110 + params.put("timestamp", System.currentTimeMillis()/1000+"");
  111 + String url = OpenUtil.buildURL("http://api.cnlive.com/open/api2/zbsc/getLiveActivityPlayInfo", params, "672db30805f848f59ec3728f8347a4a0");
  112 + HttpURLConnection connection;
  113 + try {
  114 + URL requestUrl = new URL(url);
  115 + connection = (HttpURLConnection)requestUrl.openConnection();
  116 + connection.setRequestMethod("GET");
  117 + connection.setDoInput(true);
  118 + connection.setDoOutput(true);
  119 + connection.connect();//连接
  120 +
  121 + //获得返回值
  122 + if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
  123 + InputStream in = connection.getInputStream();
  124 + String currentLine = "";
  125 + if(in != null){
  126 + BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8"));
  127 + while((currentLine = br.readLine()) != null){
  128 + result += currentLine;
  129 + }
  130 + br.close();
  131 + }
  132 + }
  133 + }catch (Exception e) {
  134 + e.printStackTrace();
  135 + }
  136 +
  137 + if(BaseUtil.notBlank(result)) {
  138 + JSONObject resultJson = JSONObject.parseObject(result);
  139 + return resultJson.getJSONObject("data").getString("hls_url_rate2");
  140 + }
  141 +
  142 + return "";
  143 + }
  144 +```
0 145 \ No newline at end of file
... ...