We have a program used html5 audio, it works well in IE, Chrome, Firefox, but failed in Safari of IOS. Could you help?
zk/html:
<audio id="au_captcha" src="sound/A.wav" height="0px" width="0px"></audio>
Java:
@Listen("onOK=#tbtnPlaySound")
public void onOKTbtnPlaySound() {au_captcha.setSrc("/playSoundServlet?r=" + Math.random());
au_captcha.setAutostart(true);
au_captcha.setLoop(false);
au_captcha.setVisible(true);
au_captcha.invalidate();
}
playSoundServlet
private void playCaptchaSound(HttpServletRequest request,
HttpServletResponse response, HttpSession session) {
String sPath = request.getSession().getServletContext()
.getRealPath("/").toString().replace("\\", "/") + "sound/";
// Set to expire far in the past.
response.setDateHeader("Expires", 0);
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
response.setContentType("audio/mpeg");
// String code ="ABCD";
String code = (String) request.getSession().getAttribute("verification.code");
if (StringUtils.isEmpty(code)) {
return;
} else {
code = code.toUpperCase();
}
byte[] audioBytes = AudioCaptcha.getMP3Bytes(code, sPath);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
// write the data out
out.write(audioBytes);
out.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
even I visit audio by url like "https://domain/projectname/sound/A.wav", it still failed in production, production server is apache httpd.
but I it's OK in my develop environment (config apache ssl). Both of above already import the valid certificate.