Search code examples
javahtmlaudiohtml5-audiotapestry

Tapestry 5.4 and HTML5 audio tag


I am using Tapestry 5.4-beta26 to create a web site. I want to play a sound on my Index.tml page. For that I am using HTML5 audio tag. This is the code for audio tag:

<audio preload="auto" controls="true">
    <source src="E:\sound.mp3" />
</audio>

On the page player looks like this
enter image description here

When I use the same code in regular html page it works like it should. Can you tell me what the problem is?


Solution

  • This is not a Tapestry issue. It's a browser security issue. Any HTML page served by a web server (your Tapestry app is running in a web server/servlet container such as Jetty or Tomcat) needs to access resources through the web server, not via the local file system. Put your sound.mp3 file in a directory served by your web server (e.g. within your Tapestry project), change the src attribute to match, and it will work fine.