Commit f79a04618531deb739e430394430fd296371715e

Authored by 刘炯
1 parent 5640f9f9

1

8.直播云/1.2 获取flash直播URL接口.md
1 1 ### 获取RTMP直播播放URL接口
2 2 -----
3   -#### URL: http://api.cnlive.com/open/api2/play/IPS/liveplayBySWF
  3 +#### URL: http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF
4 4 -----
5   -#### 接口说明: 返回RTMP/FLV直播播放地址 (供 swf或 PC页面 调用)
  5 +#### 接口说明: 接口返回json,json数据(location属性)包含RTMP/FLV直播播放地址 (供 swf或 PC页面 调用)
6 6 -----
7 7 #### 请求方式: HTTP GET
8 8 -----
... ... @@ -18,5 +18,59 @@
18 18 | retry | int | false | 重试次数,在0~4之间累加 |
19 19 | rate | int | false | 1-流畅,2-标清,3-高清,4-超清,不传为2,EPG接口会返回实际的码流路数--标清为必须项|
20 20  
  21 +#### 返回结果
21 22  
22   -#### 页面播放DEMO:
23 23 \ No newline at end of file
  24 +| 参数名 | 参数类型 | 必选 | 参数说明 |
  25 +| :----------- | :------: | :------: | :------: |
  26 +| errorCode | string | true | 错误码:0 成功 |
  27 +| errorMessage| string | true | 错误类型描述 |
  28 +| location| string | true | 直播流地址 |
  29 +
  30 +```json
  31 + {
  32 + "errorCode":"0",
  33 + "errorMessage":"成功",
  34 + "location":"rtmp://wsrtmp4.live.cnlive.com/cdn/xinyingshi?wsSecret=a1b8ee5edd76fc8c80eda08cc03bec10&wsTime=57982548"
  35 + }
  36 +```
  37 +
  38 +#### 页面播放DEMO:
  39 +
  40 +####java 示例:
  41 +
  42 +``` java
  43 + public String getFlashLive() {
  44 + String result = "";
  45 + String mp4Url = "http://api.cnlive.com/open/api3/play/IPS/liveplayBySWF?channelID=xinyingshi&sp_id=iqhpk8pl19";
  46 + try {
  47 + URL requestUrl = new URL(mp4Url);
  48 + connection = (HttpURLConnection)requestUrl.openConnection();
  49 + connection.setRequestMethod("GET");
  50 + connection.setDoInput(true);
  51 + connection.setDoOutput(true);
  52 + connection.connect();//连接
  53 +
  54 + //获得返回值
  55 + if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
  56 + InputStream in = connection.getInputStream();
  57 + String currentLine = "";
  58 + if(in != null){
  59 + BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8"));
  60 + while((currentLine = br.readLine()) != null){
  61 + result += currentLine;
  62 + }
  63 + br.close();
  64 + }
  65 + }
  66 + }catch (Exception e) {
  67 + e.printStackTrace();
  68 + }
  69 +
  70 + if(BaseUtil.notBlank(result)) {
  71 + resultJson = JSONObject.parseObject(result);
  72 + return resultJson.getString("location");
  73 + }
  74 +
  75 + return "";
  76 + }
  77 +```
24 78 \ No newline at end of file
... ...