API can only be initiated by a user gesture event handler
Hi,
I am trying to play an html5 audio in a vmousedown handler in chrome on Android, but it says "API can only be initiated by a user gesture event handler". The issue is, obviously, that I am doing in an event handler and responding to a user gesture. The code is like below:
- <a id="btn1" data-role="button" data-inline="true" data-mini="true">Play</a>
- <audio class="audio" id="audio1"></audio>
- <script >
- $("btn1").on("vmousedown", function() {
- var a = $("audio1")[0];
- a.play();
- });
- </script>
Any idea?
Many thanks!