1.2 获取flash直播URL接口.md
1.89 KB
请求参数说明:
| 参数名 | 参数类型 | 必选 | 参数说明 |
|---|---|---|---|
| appId | string | true | 应用ID |
| channelId | string | true | 直播频道或 devID_主播ID |
| uid | string | false | 用户标识(uuid_时间戳) |
| sid | string | false | 用户ID |
| retry | int | false | 重试次数,在0~4之间累加 |
| rate | int | false | 1-流畅,2-标清,3-高清,4-超清,不传为2,EPG接口会返回实际的码流路数--标清为必须项 |
返回结果 json
{
"errorMessage":"成功",
"data":{
"location":"rtmp://wsrtmp4.live.cnlive.com/cdn/xinyingshi?wsSecret=f10722a1a2ffd198772b2ac8cf1c0afb&wsTime=57a3f066"
},
"errorCode":"0"
}
java 示例
public String getFlashUrl() {
String result = "";
String mp4Url = "http://api.cnlive.com/open/api2/live_ips/liveplayBySWF?channelID=xinyingshi&appId=iqj730vn11";
try {
URL requestUrl = new URL(mp4Url);
connection = (HttpURLConnection)requestUrl.openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();//连接
//获得返回值
if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
InputStream in = connection.getInputStream();
String currentLine = "";
if(in != null){
BufferedReader br = new BufferedReader(new InputStreamReader(in,"utf-8"));
while((currentLine = br.readLine()) != null){
result += currentLine;
}
br.close();
}
}
}catch (Exception e) {
e.printStackTrace();
}
if(BaseUtil.notBlank(result)) {
resultJson = JSONObject.parseObject(result);
result = resultJson.getJSONObject("data").getString("location");
}
return result;
}