我想使用Java将实时视频传输到播放器(FlowPlayer,JW Player等)
我找到了一个例子,但它使用的是java servlets:
Servlet代码:
byte[] data = findingService.getVideo(params.id)
response.setContentType("video/avi")
response.setContentLength(data.length)
println "length=${data.length}"
byte[] content = new byte[1024];
BufferedInputStream is = new BufferedInputStream(new ByteArrayInputStream(data));
OutputStream os = response.getOutputStream();
while (is.read(content) != -1) {
println "... write bytes";
os.write(content);
}
is.close()
os.close()
流程生成代码:
<a href="/finding/video.avi?id=99" style="display:block;width:215px;height:150px;" id="flowplayer_99">
<object width="100%" height="100%" id="flowplayer_99_api" name="flowplayer_99_api" data="/swf/flowplayer-3.2.4.swf?0.1476281308569014" type="application/x-shockwave-flash">
<param name="allowfullscreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="quality" value="high">
<param name="cachebusting" value="true">
<param name="bgcolor" value="#000000">
<param name="flashvars" value="config={"playerId":"flowplayer_99","clip":{"url":"/finding/video.avi?id=99"},"playlist":[{"url":"/finding/video.avi?id=99"}]}">
</object>
</a>
是否可以使用套接字而不是servlet来提供视频?
有人可以使用java套接字或nio频道为我提供示例吗?
由于