The following code works fine with all the other browsers except IE, wherein once the audio is played and the next button is shown, you can yet click on the audio and hear it again. As this is a survey it is unfair to the participant if someone can hear it more than once. Can you please tell me how come it is working fine in other browser but not in IE and how it can be fixed?
I want the users not to be able to hear again (even if they click on the Play Story button) once the "click to continue" button appears.
Now that you know how the auditory stories will sound, you are ready to listen to and comprehend the two auditory stories in this study. The first auditory story is titled, “The Honey Gatherer’s Three Sons.” Press the “Play Story” button to begin listening to the story; after you have finished listening to the story, you will answer a set of questions about the story.
<div>
<p> </p>
<audio controls="" id="audio2" style="display:none"><source src="http://langcomplab.net/Honey_Gatherers_Master.webm" style="width:50%" type="audio/webm" /> <source src="http://langcomplab.net/Honey_Gatherers_Master.mp3" style="width:50%" type="audio/mp3" /> Your browser doesn't support this audio format.</audio>
</div>
<p> </p>
<div><button name="play" onclick="disabled=true" style="height:25px; width:200px" type="button">Play Story</button></div>
and here is the javascript:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place Your Javascript Below This Line*/
var aud = document.getElementById('audio2');
this.questionclick = function(event,element){
if((element.type == "button") && (element.name == "play"))
{
aud.play();
}
}
});
UPDATE: I changed it to the following in HTML:
<div><button name="play" style="width: 200px; height: 25px;" type="button">Play Story</button>
and the following in the js:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place Your Javascript Below This Line*/
var aud = document.getElementById('audio1');
this.questionclick = function(event,element){
if((element.type == "button") && (element.name == "play"))
{
aud.play();
element.disabled = true;
}
}
});
But yet, after the audio is played and continue button is shown, the user can click on the play story button in IE and hear it again while this doesn't happen in other browsers. Is there any option in JavaScript or HTML5 to avoid the user to play the audio after once it has been played which can work for IE?
disabled=true
from the button, and in the JS addelement.disabled = true
immediately afteraud.play()
– levi