我开发了基于Spring的Web应用程序来观看视频。它通过桌面工作得很好。但如果我尝试从iPad和iPhone打开我的应用程序我无法播放视频。因为jwplayer无法从服务器获取数据。 jwplayer显示错误,如“视频无法加载,因为服务器或网络失败,或者因为格式不受支持”,同时服务器端错误
Caused by: java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at org.mortbay.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:170)
at org.mortbay.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:221)
at org.mortbay.jetty.HttpGenerator.flush(HttpGenerator.java:725)
我搜索网并找出原因。 客户端(iPad / iPhone)终止服务器连接。这是断管错误。请参阅我的服务器端代码
private void sendFile(HttpServletResponse response, String filename, String directory, String contentType, String extention) throws IOException, InterruptedException {
final String file = directory + File.separator + filename + "." + extention;
response.setContentLength((int) new File(file).length());
response.setContentType(contentType);
try {
FileInputStream inputStream = new FileInputStream(file);
ServletOutputStream outputStream = response.getOutputStream();
IOUtils.copyLarge(inputStream, outputStream);
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
} catch (Exception exp) {
exp.printStackTrace();
}
response.setStatus(HttpServletResponse.SC_OK);
}
将inputStream复制到outputStream,IOUtils.copyLarge(inputStream,outputStream)时发生了断管。
我该如何解决这个问题。任何人都请以适当的方式指导我..
先谢谢..
答案 0 :(得分:1)
解决哪个问题?不支持的视频问题的解决方案是发送支持的视频类型,破解管道例外的解决方案是解决不支持的视频问题。