I’m trying to use the onClick function to make a button play an audio file and then disable after a specified length of time (to line up with the end of the audio file). Basically I’m trying to set up a Mission Impossible-esque thing where, when the button is clicked, the audio file plays and at the end of the recording the button disables (the message “self-destructing”). I can get the file to play but I can’t figure out how to get the button to disable using the script code. This is what I’ve got so far. I tried both document.getElementById("briefingButton").this.disabled="true"
and document.getElementById("briefingButton").style.display="none"
and neither works.
<p id="briefingButton"><input type="button" value="Click for briefing" onclick="playMusic(); disableButton()" />
<script>
function playMusic(){
var music = new Audio('/Users/devonhunt/Documents/ADVENTURE WEDDING/Mission briefings/dom mk1.mp3');
music.play();
}
setTimeout(function disableButton() {
document.getElementById("briefingButton").this.disabled="true";
}, 1080)
</script></p>