Sure! Thanks so much! :-)Qualtrics.SurveyEngine.addOnload(function(){ //create variable to track play count var playcount = 0; //create variable to track page refresh count var refreshcount = 0; //Get audio element //name "audiofile" this whatever you name your audio element ID is within your HTML var audio = document.getElementById("audiofile1"); audio.volume = 1; //set audio volume to 1 // CREATE playAudio() FUNCTIONfunction playAudio() { playcount++; //increase playcount number by 1 console.log(playcount); var button = document.getElementById("audiobutton1"); //grab button id button.style.visibility = "hidden"; //hide the button so that it can't be played anymore audio.play(); //play the audio one last time //update play_count embedded data to current playcount number Qualtrics.SurveyEngine.setEmbeddedData("play_count", playcount); }; audio.onended = function() { if (playcount < 1){ var button = document.getElementById("audiobutton1"); //grab button id button.style.visibil
Thanks so much! I've just tried both but unfortunately neither of them works. Let me know if you can think of anything else :-)
Hi AHammell, thanks so much for your reply, which I've just seen (clearly I must have missed the notification)!I've added the new bit of coding but it doesn't seem to make any difference. The audio button disappears when it's supposed to, but this was already the case. The problem is that, even though the button is no longer there, you can still play the audio by clicking on the space where the button used to be.Do you know if there is a way to work around this? Perhaps by deactivating controls/mouse movements after a given audio has been played a certain number of times?I have no idea whether this is possible at all but I'm trying to think outside the box :-)Thanks so much for your help!Chiara
Hi AHammell, thanks for your reply and apologies for getting back to you so late. In the end I've avoided the issue by using Qualtrics Media Library, so everything looks good on that front.The codes you've kindly provided in this thread work fine. The only problem is that, although the 'Play' button disappears once the audio has been played the allowed amount of times (in my case, once), one can still re-play the audio by clicking on the empty area where the 'Play' button used to be. In other words, the button is hidden but that doesn't necessarily prevent people from playing the audio. Is this normal, or is it just an issue with the Preview mode?Is there a way to make sure the playing function is fully disallowed/deactivated after an audio has been played a given amount of times?Thanks for your help!
Hi AHammell! Thanks so much for providing all this coding!!! Unfortunately the HTML code is not working for me anymore. It used to work when I uploaded my audio files through the "rich content editor", but I don't seem to be able to do that anymore, and inserting an URL from a SoundCloud or Google drive audio file into the tag you provided is not working at the moment. The button is there, but the audio isn't playing. Do you know what I could be getting wrong?Thanks a lot!Chiara
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.