Audio files hosted in Wildfly would not play in google chrome
sdptroy3 Jun 27, 2018 8:45 AMHi,
I have hosted some audio file in wildfly in a static directory /var/audio/ and updated undertow subsystem in standalone.xml as follows
<server name="default-server">
<http-listener name="default" max-parameters="5000" max-post-size="0" socket-binding="http" redirect-socket="https"/>
<https-listener name="httpsServer" max-parameters="5000" max-post-size="0" security-realm="ApplicationRealm" socket-binding="https"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<location name="/AUDIO" handler="audio"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
<file name="audio" directory-listing="true" path="/var/audio"/>
</handlers>
Now if I open the link "https://WILDFLY_URL:8443/AUDIO/" in Google Chrome , the content of the directory is listed. But whenever I click some audio file link, it opens a new tab with <audio> tag but nothing is loaded. I can not play anything. This situation does not arise in Firefox, when clicking a link prompts user to save the file. I have also made an sample html file with audio tag, but nothing happens there also. The sample code is
<html>
<head>
<title>Audio Demo</title>
<script type="text/javascript">
function updateSource(){
var audio = document.getElementById('wavSource');
audio.src = 'https://SERVER_URL:8443/FILE_PATH/FILE_NAME.wav';
var a = document.getElementById('audio');
a.load();
}
</script>
</head>
<body>
<audio id="audio" controls="controls">
<source id="wavSource" src="" type="audio/wav"></source>
Your browser does not support the audio format.
</audio>
<button onclick="updateSource();">Item1</button>
</body>
I dont know what is that I am doing wrong here. I would greatly appreciate if someone shed some light upon this.
Thank you