Commit a45fbe6ae9ffd13127bebf695afeca698491730e
1 parent
0efcb796
update
Showing
1 changed file
with
79 additions
and
28 deletions
8.直播云/1.1 获取直播活动信息接口.md
| 1 | 1 | /* |
| 2 | -Title: 1.1 获取单个分类接口 | |
| 3 | -Sort: 11 | |
| 2 | +Title: 1.1 获取直播活动信息接口 | |
| 4 | 3 | */ |
| 5 | 4 | |
| 6 | 5 | ### 接口描述 ### |
| 7 | 6 | |
| 8 | 7 | |
| 9 | 8 | ### 接口地址 ### |
| 10 | -http://icms.staff.cnlive.com/icms_service/api/getCategoryTree.do?appId=movie&catalogID=.. | |
| 9 | +http://api.cnlive.com/open/api2/zbsc/getLiveActivityPlayInfo | |
| 11 | 10 | |
| 12 | 11 | ### 接口协议 ### |
| 13 | 12 | HTTP GET |
| 14 | 13 | |
| 15 | 14 | ### 接口请求参数 ### |
| 16 | -- siteID:站点ID | |
| 17 | -- catalogID:节点ID | |
| 15 | +- sp_id:应用ID | |
| 16 | +- customID:活动ID | |
| 17 | +- timestamp:时间戳,精确到秒 | |
| 18 | 18 | |
| 19 | 19 | ### 返回值 ### |
| 20 | 20 | 返回JSON格式的节目元数据信息,json示例如下: |
| 21 | -<pre><code>{ | |
| 22 | -Id: 1, | |
| 23 | -title: "", | |
| 24 | -parentI: "", | |
| 25 | -children: "" | |
| 21 | + | |
| 22 | +``` json | |
| 23 | +{ | |
| 24 | + "ret":"0", | |
| 25 | + "mp4_url_rate1":"http://api.cnlive.com/open/api3/play/IPS/getH5Epg2?cid=xinyingshi&sp_id=iqhpk8pl19", | |
| 26 | + "mp4_url_rate0":"http://api.cnlive.com/open/api3/play/IPS/getH5Epg2?cid=xinyingshi&sp_id=iqhpk8pl19", | |
| 27 | + "mp4_url_rate3":"", | |
| 28 | + "mp4_url_rate2":"", | |
| 29 | + "status":"1", | |
| 30 | + "hls_url_rate1":"http://api.cnlive.com/open/api3/play/IPS/getH5Epg2?cid=xinyingshi&sp_id=iqhpk8pl19", | |
| 31 | + "hls_url_rate0":"http://api.cnlive.com/open/api3/play/IPS/getH5Epg2?cid=xinyingshi&sp_id=iqhpk8pl19", | |
| 32 | + "hls_url_rate3":"", | |
| 33 | + "hls_url_rate2":"", | |
| 34 | + "msg":"请求成功" | |
| 26 | 35 | } |
| 27 | -<code></pre> | |
| 36 | +``` | |
| 28 | 37 | |
| 29 | 38 | JSON属性说明: |
| 39 | + | |
| 30 | 40 | <table style="font-size:14px" > |
| 31 | 41 | <tr> |
| 32 | 42 | <td>字段名称</td> |
| 33 | 43 | <td>描述</td> |
| 34 | - <td>是否可控</td> | |
| 35 | 44 | <td>备注</td> |
| 36 | 45 | </tr> |
| 37 | 46 | <tr> |
| 38 | - <td>Id</td> | |
| 39 | - <td>节点ID</td> | |
| 40 | - <td>否</td> | |
| 41 | - <td></td> | |
| 47 | + <td>ret</td> | |
| 48 | + <td>返回码</td> | |
| 49 | + <td>0:成功</td> | |
| 42 | 50 | </tr> |
| 43 | 51 | <tr> |
| 44 | - <td>title</td> | |
| 45 | - <td>节点名称</td> | |
| 46 | - <td>否</td> | |
| 52 | + <td>msg</td> | |
| 53 | + <td>返回信息</td> | |
| 47 | 54 | <td></td> |
| 48 | 55 | </tr> |
| 49 | 56 | <tr> |
| 50 | - <td>parentI</td> | |
| 51 | - <td>父节点ID</td> | |
| 52 | - <td>是</td> | |
| 53 | - <td>为空没有该节点,表示是一级分类</td> | |
| 57 | + <td>status</td> | |
| 58 | + <td>状态</td> | |
| 59 | + <td>0:未开始/1:直播中/2:直播结束、回放生成中/3:已结束</td> | |
| 60 | + </tr> | |
| 61 | + <tr> | |
| 62 | + <td>mp4_url_rate1</td> | |
| 63 | + <td>播放地址</td> | |
| 64 | + <td></td> | |
| 54 | 65 | </tr> |
| 55 | 66 | <tr> |
| 56 | - <td>children</td> | |
| 57 | - <td>当前节点下子节点数组</td> | |
| 58 | - <td>是</td> | |
| 59 | - <td>包含若干个节点,节点下也是id、title、chiildren,为空则没有该节点结构</td> | |
| 67 | + <td>hls_url_rate1</td> | |
| 68 | + <td>播放地址</td> | |
| 69 | + <td></td> | |
| 60 | 70 | </tr> |
| 61 | 71 | </table> |
| 62 | 72 | |
| 63 | 73 | |
| 64 | - | |
| 74 | +参数需进行加密,示例: | |
| 75 | +``` java | |
| 76 | +public String getPlayVideo(ModelMap model,HttpServletRequest request) { | |
| 77 | + String result = ""; | |
| 78 | + Map params = new HashMap<>(); | |
| 79 | + params.put("sp_id", "iqhpk8pl19"); | |
| 80 | + params.put("customID", "d849bb4277be42799df3ffc21654d949"); | |
| 81 | + params.put("timestamp", System.currentTimeMillis()/1000+""); | |
| 82 | + String url = OpenUtil.buildURL("http://api.cnlive.com/open/api2/zbsc/getLiveActivityPlayInfo", params, "672db30805f848f59ec3728f8347a4a0"); | |
| 83 | + HttpURLConnection connection; | |
| 84 | + try { | |
| 85 | + URL requestUrl = new URL(url); | |
| 86 | + connection = (HttpURLConnection)requestUrl.openConnection(); | |
| 87 | + connection.setRequestMethod("GET"); | |
| 88 | + connection.setDoInput(true); | |
| 89 | + connection.setDoOutput(true); | |
| 90 | + connection.connect();//连接 | |
| 91 | + | |
| 92 | + //获得返回值 | |
| 93 | + if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){ | |
| 94 | + InputStream in = connection.getInputStream(); | |
| 95 | + String currentLine = ""; | |
| 96 | + if(in != null){ | |
| 97 | + BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8")); | |
| 98 | + while((currentLine = br.readLine()) != null){ | |
| 99 | + result += currentLine; | |
| 100 | + } | |
| 101 | + br.close(); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + }catch (Exception e) { | |
| 105 | + e.printStackTrace(); | |
| 106 | + } | |
| 107 | + | |
| 108 | + if(BaseUtil.notBlank(result)) { | |
| 109 | + JSONObject resultJson = JSONObject.parseObject(result); | |
| 110 | + model.put("videoInfo", resultJson); | |
| 111 | + } | |
| 112 | + | |
| 113 | + return "play_demo"; | |
| 114 | + } | |
| 115 | +``` | |
| 65 | 116 | \ No newline at end of file | ... | ... |