Playing an audio clip ONLY once | XM Community
Skip to main content

Hi everyone! I am trying to restrict the number of times participants can play an audio clip in my survey. Ideally, participants will only be able to listen to the audio clip once before proceeding to the next question. I've also read other posts about having the audio clip automatically play or having the survey automatically skip to the next question after a certain amount of time has been spent on the page; however, I want the participants to have full control of when they press "play." Any help would be much appreciated! Thanks 🙂

Check out my comment on your other post about how to modify my script! 🙂
https://www.qualtrics.com/community/discussion/13536/how-do-you-restrict-the-number-of-times-an-audio-clip-is-played#latest
Let me know if anything's confusing.


@AHammell 

I would appreciate it if you could help me resolve the issue with my audio. I followed your instructions to play the audio only once, but I'm encountering problems. The audio sometimes has an echo, plays twice, or doesn't produce any sound at all. Your assistance would be greatly appreciated.

Here is the link of survey in the case you want to take a look at it: https://ufl.yul1.qualtrics.com/jfe/preview/previewId/453ac8ec-1584-491e-a099-225d746590c8/SV_2hKeKa2XWWmsKa2/BL_3JDfUP9uswIUkS2?Q_SurveyVersionID=current

 

I used these codes:

for Jv Script: Qualtrics.SurveyEngine.addOnload(function()
{
    var buttonNum=1;
    jQuery("#audiobutton1").on("click", playAudio(buttonNum));
});

 

for HTML: <button type="button" id="audiobutton1">Play Audio</button>
<audio src="https://ufl.yul1.qualtrics.com/ControlPanel/File.php?F=F_pXTqdPBA1BKUecT" id="audiofile1"> </audio>

For header: <script>
function playAudio(buttonNum) {
  var button = document.getElementById("audiobutton"+buttonNum); //grab button id
  var audio = document.getElementById("audiofile"+buttonNum); //grab audio id
  audio.play(); //play the audio once 
  button.style.visibility = "hidden"; //hide the button so that it can't be played anymore
 }
</script>

 

And finally, for the survey flow, I used the following image.

 

 

 


Leave a Reply