Commit bd62320fdf2bb33b26e6804f5c24998cc6f1cb50
1 parent
374fb046
2
Showing
1 changed file
with
48 additions
and
1 deletions
02.直播云/1.2 获取flash直播URL接口.md
| @@ -18,5 +18,52 @@ | @@ -18,5 +18,52 @@ | ||
| 18 | | retry | int | false | 重试次数,在0~4之间累加 | | 18 | | retry | int | false | 重试次数,在0~4之间累加 | |
| 19 | | rate | int | false | 1-流畅,2-标清,3-高清,4-超清,不传为2,EPG接口会返回实际的码流路数--标清为必须项| | 19 | | rate | int | false | 1-流畅,2-标清,3-高清,4-超清,不传为2,EPG接口会返回实际的码流路数--标清为必须项| |
| 20 | 20 | ||
| 21 | +#### 返回结果 json | ||
| 22 | +```json | ||
| 23 | + { | ||
| 24 | + "errorMessage":"成功", | ||
| 25 | + "data":{ | ||
| 26 | + "location":"rtmp://wsrtmp4.live.cnlive.com/cdn/xinyingshi?wsSecret=f10722a1a2ffd198772b2ac8cf1c0afb&wsTime=57a3f066" | ||
| 27 | + }, | ||
| 28 | + "errorCode":"0" | ||
| 29 | + } | ||
| 30 | +``` | ||
| 21 | 31 | ||
| 22 | -#### 页面播放DEMO: | ||
| 23 | \ No newline at end of file | 32 | \ No newline at end of file |
| 33 | +#### java 示例 | ||
| 34 | + | ||
| 35 | +```java | ||
| 36 | + public String getFlashUrl() { | ||
| 37 | + String result = ""; | ||
| 38 | + String mp4Url = "http://api.cnlive.com/open/api2/live_ips/liveplayBySWF?channelID=xinyingshi&appId=iqhpk8pl19"; | ||
| 39 | + try { | ||
| 40 | + URL requestUrl = new URL(mp4Url); | ||
| 41 | + connection = (HttpURLConnection)requestUrl.openConnection(); | ||
| 42 | + connection.setRequestMethod("GET"); | ||
| 43 | + connection.setDoInput(true); | ||
| 44 | + connection.setDoOutput(true); | ||
| 45 | + connection.connect();//连接 | ||
| 46 | + | ||
| 47 | + //获得返回值 | ||
| 48 | + if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){ | ||
| 49 | + InputStream in = connection.getInputStream(); | ||
| 50 | + String currentLine = ""; | ||
| 51 | + if(in != null){ | ||
| 52 | + BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8")); | ||
| 53 | + while((currentLine = br.readLine()) != null){ | ||
| 54 | + result += currentLine; | ||
| 55 | + } | ||
| 56 | + br.close(); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + }catch (Exception e) { | ||
| 60 | + e.printStackTrace(); | ||
| 61 | + } | ||
| 62 | + if(BaseUtil.notBlank(result)) { | ||
| 63 | + resultJson = JSONObject.parseObject(result); | ||
| 64 | + result = resultJson.getJSONObject("data").getString("location"); | ||
| 65 | + } | ||
| 66 | + return result; | ||
| 67 | + } | ||
| 68 | +``` | ||
| 69 | + | ||
| 70 | +#### [页面播放DEMO](http://open.cnlive.com/demo/live/flash_live_demo.html) | ||
| 24 | \ No newline at end of file | 71 | \ No newline at end of file |