因为本身的公司的项目须要调用视频地址ajax
1:当为连接时:直接在播放器用数据库查找的地址数据库
2:当为外部连接时:直接用window.location.href('数据库查找的地址')json
3:当为H5连接时:使用<ifram src="数据库查找的地址">播放跨域
4:当为其他网站连接时,要去第三方网站读取json信息而后把json数据做为url放在播放器中app
当为4时,我使用json时会出格式错误jsonp
当用jsonp解决跨域问题时,会出现返回格式接收不到网站
因此我用url
public static String analysisUrl(String url){ HttpURLConnection httpConnection = null; String output = ""; try { URL targetUrl = new URL(url); httpConnection = (HttpURLConnection) targetUrl.openConnection(); httpConnection.setDoOutput(true); httpConnection.setRequestMethod("GET"); httpConnection.setRequestProperty("Content-Type", "application/json"); InputStreamReader isr = new InputStreamReader(httpConnection .getInputStream(),"utf-8"); BufferedReader responseBuffer = new BufferedReader(isr); output = responseBuffer.readLine(); } catch (Exception e) { } finally { httpConnection.disconnect(); } return output; }