用官网示例来实现rtsp流视频投放:目前官网上提供的示例http://support.supermap.com.cn:8090/webgl/examples/webgl/editor.html#RTSP
是实现不了,没有效果,通过调试代码发现官网通过StreamEdian播放器+webSocket技术来实现视频流的获取和播放
目前调试发现代码
Streamedian.player('trailer', {
socket: "ws://127.0.0.1/myWebSocket"
});
socket的参数只支持ws || wss格式的请求。
我自己写了一个请求,读取本地的mp4视频,返回bytebuffer,代码断片如下
FileInputStream file = null;
ByteBuffer btf = ByteBuffer.allocate(8000);
String path ="C:\\Users\\Administrator.USER-20190906OF\\Desktop\\NewFile4\\big_buck_bunny.mp4";
try {
file = new FileInputStream(path);
int size = 8000 ;
int len =-1;
byte [] data = new byte[size];
int num = 0;
while((len=file.read(data))!=-1) {
btf = ByteBuffer.wrap(data);
BinaryMessage bMessage = new BinaryMessage(btf);
session.sendMessage(bMessage);
System.out.println(num);
++num ;
}
file.close();
file=null;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
}
前端错误 提示data.indexOf is not a function: