添加直接播放
This commit is contained in:
parent
aac202432d
commit
1e13507381
14
README.md
14
README.md
@ -44,10 +44,16 @@ easy.flv.host=http://localhost:8200
|
|||||||
|
|
||||||
### 第五步:不想实现interface使用
|
### 第五步:不想实现interface使用
|
||||||
原地址:rtsp://XXXXXXXX <br>
|
原地址:rtsp://XXXXXXXX <br>
|
||||||
- protocol:rtsp
|
```Java
|
||||||
- url:XXXXX
|
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||||
- 流转换地址:GET http://ip:port/get/flv/hls/stream_rtsp?url=XXXXXX
|
|
||||||
- 浏览器直接播放测试: GET http://ip:port/flv/hls/stream_rtsp?url=XXXXXX
|
String url = "rtsp://XXXXXXXX";
|
||||||
|
String encodedUrl = java.net.URLEncoder.encode(url, "UTF-8");
|
||||||
|
System.out.println("编码:" + encodedUrl);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- 流转换地址:GET http://ip:port/get/flv/hls/stream?url=编码后的地址
|
||||||
|
- 浏览器直接播放测试: GET http://ip:port/flv/hls/stream?url=编码后的地址
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FLV流转换
|
* FLV流转换
|
||||||
@ -32,11 +33,12 @@ public class FLVController {
|
|||||||
service.open(channel,url, response, request);
|
service.open(channel,url, response, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@GetMapping(value = "/get/flv/hls/stream_{protocol}")
|
@GetMapping(value = "/get/flv/hls/stream")
|
||||||
public void open1(@PathVariable(value = "protocol") String protocol,String url, HttpServletResponse response,
|
public void open1(String url, HttpServletResponse response,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) throws UnsupportedEncodingException {
|
||||||
if(!StringUtils.isEmpty(url)&&!StringUtils.isEmpty(protocol)){
|
if(!StringUtils.isEmpty(url)){
|
||||||
service.open(protocol+"://"+url, response, request);
|
String decodedUrl = java.net.URLDecoder.decode(url, "UTF-8");
|
||||||
|
service.open(decodedUrl, response, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import org.springframework.ui.Model;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FLV流转换
|
* FLV流转换
|
||||||
*
|
*
|
||||||
@ -25,9 +27,10 @@ public class FLVPlayController {
|
|||||||
model.addAttribute("height", flvConfig.getHeight());
|
model.addAttribute("height", flvConfig.getHeight());
|
||||||
return "video";
|
return "video";
|
||||||
}
|
}
|
||||||
@GetMapping(value = "/flv/hls/stream_{protocol}")
|
@GetMapping(value = "/flv/hls/stream")
|
||||||
public String getAppHtml1(@PathVariable(value = "protocol") String protocol,String url, Model model) {
|
public String getAppHtml1(String url, Model model) throws UnsupportedEncodingException {
|
||||||
String videoPath=flvConfig.getHost()+"/get/flv/hls/stream_"+protocol+"?url="+url;
|
String decodedUrl = java.net.URLDecoder.decode(url, "UTF-8");
|
||||||
|
String videoPath=flvConfig.getHost()+"/get/flv/hls/stream?url="+decodedUrl;
|
||||||
model.addAttribute("videoPath", videoPath);
|
model.addAttribute("videoPath", videoPath);
|
||||||
model.addAttribute("wight", flvConfig.getWight());
|
model.addAttribute("wight", flvConfig.getWight());
|
||||||
model.addAttribute("height", flvConfig.getHeight());
|
model.addAttribute("height", flvConfig.getHeight());
|
||||||
|
Loading…
Reference in New Issue
Block a user