添加SRC到视频信号源时的base64添加到src
问题描述:
我从Oracle数据库中使用Java和发送响应与这里的base64值检索视频不工作是我的Java代码添加SRC到视频信号源时的base64添加到src
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ String video64="";
System.out.println("service");
try {
PreparedStatement ps=cn.prepareStatement("select * from video ");
ResultSet rs=ps.executeQuery();
rs.next();
Blob vedio=rs.getBlob(1);
System.out.println("try");
if(vedio !=null)
{
byte videobytes[]=vedio.getBytes(1,(int)vedio.length());
video64 = DatatypeConverter.printBase64Binary(videobytes);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(video64);
response.getWriter().write(video64);
}
here is my html
<video controls>
<source type="video/mp4" id="v">
</video>
我使用AJAX调用发送请求并使用jquery 加入我的<source type="video/mp4" id="v">
响应这里是AJAX
$("#sub").click(function(){
$.ajax({
url:"RetriveVedio",
method: "get",
dataType: 'text',
success:function(response){
console.log(response);
$("#v").attr("src",'data:video/mp4;base64,'+response);
$("#v").load();
}
});
});
但src
不获取添加到源,并base64
价值也没有工作video tag
这是base64价值,我得到的回应AAAAGGZ0eXBtcDQyAAAAAG1wNDFpc29tBNjldm1kYXQAAAAAAAAAEAA=
这是什么问题?
答
与上述代码的一切都很好。但blob
是不正确的,当我插入视频使用java到database
视频未正确转换为byteStream
。 这就是为什么响应AAAAGGZ0eXBtcDQyAAAAAG1wNDFpc29tBNjldm1kYXQAAAAAAAAAEAA=
是错误的。 这就是为什么上面的代码没有工作