日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

对于get请求是视频,同时将视频流传给前端问题

發布時間:2024/9/30 HTML 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 对于get请求是视频,同时将视频流传给前端问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
@RequestMapping("/bbb")public String text(HttpServletRequest re, HttpServletResponse rs) { CloseableHttpClient httpClient = null; /*解決信任SSL證書(PKIX path building failed問題) */try {SSLContext sslContext = SSLContextBuilder.create().useProtocol(SSLConnectionSocketFactory.SSL).loadTrustMaterial((x, y) -> true).build();RequestConfig config = RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).build();httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).setSSLContext(sslContext).setSSLHostnameVerifier((x, y) -> true).build();} catch (Exception e) {e.printStackTrace();}String flag = "0";HttpGet httpGet = new HttpGet(url);httpGet.setHeader(new BasicHeader("Cookie", Cookie));// response 對象CloseableHttpResponse response = null;response = httpClient.execute(httpGet);// 判斷返回狀態是否為200if (response.getStatusLine().getStatusCode() == 200) {HttpEntity entity = response.getEntity();//現在用流來接受entity InputStream in=**entity.getContent();** int count = 0; //下面進行寫入字節while (count == 0) { count = Integer.parseInt(""+entity.getContentLength());//in.available(); } byte[] bytes = new byte[count]; int readCount = 0; // 已經成功讀取的字節的個數 while (readCount <= count) { if(readCount == count)break; readCount += in.read(bytes, readCount, count - readCount); } OutputStream out=null;rs.setContentType("video/mp4");out = rs.getOutputStream();out.write(bytes);out.flush();out.close();}//別忘記關閉連接 省略不寫了}

前端:

<video width="1120" height="540" controls="controls" id= "video" preload="auto"> <source src= "../bbb.do" type-"video/mp4" > </video>

最后完美解決

總結

以上是生活随笔為你收集整理的对于get请求是视频,同时将视频流传给前端问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。