Commit dd9e9e996af8915b927d6e494423a648b14e1c93
1 parent
ea48647a
2
Showing
1 changed file
with
38 additions
and
2 deletions
01.点播云/1.3 获取flash点播URL接口.md
| @@ -28,6 +28,42 @@ | @@ -28,6 +28,42 @@ | ||
| 28 | "errorCode":"0" | 28 | "errorCode":"0" |
| 29 | } | 29 | } |
| 30 | ``` | 30 | ``` |
| 31 | - | ||
| 32 | 31 | ||
| 33 | -#### [页面播放DEMO](http://open.cnlive.com/demo/live/flash_live_demo.html) | ||
| 34 | \ 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/vod_ips/vodplayBySWF?vId=xinyingshi&appId=iqj730vn11"; | ||
| 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/vod/flash_vod_demo.html) | ||
| 35 | \ No newline at end of file | 71 | \ No newline at end of file |