I would like to add a play button somewhere on the page, and when they click it, the player at the bottom will play also, then the play button will disappear. Is that possible? Thanks.
Asked
Active
Viewed 185 times
1
-
1*"Is that possible?"* Yes! Start coding! – Alexander O'Mara Feb 09 '15 at 05:02
1 Answers
1
You need a little bit JavaScript code.
Add an event-listener for the button, select the audio-tag (your player) and call the play-method. Then hide the button with the css-property "display: none;" or "visibility: hidden;" (also with JavaScript).
<button onclick="document.getElementsByTagName('audio')[0].play(); this.style.visibility = 'hidden';">play</button>
<audio controls src="demo.mp3"></audio>
Martin Wantke
- 3,250
- 26
- 16