Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
Cap number of times an audio can be played: audio button disappears but one can still play the audio

I'm preparing a survey where I ask people to listen to a number of audio files once only. To do that, I've used a javascript that hides the audio button after the audio has been played X number of times. The problem is that, although the button disappears when it should, one can still play the audio file by clicking on the empty space where the button used to be. Is there a way to avoid this - for instance by disabling controls or mouse click after an audio has been played?

Below is a part of javascript that I have at the moment, courtesy of a kind Qualtrics user. Any idea as to how I can amend it? I'm a coding newbie so any help is hugely appreciated!

Many thanks!

Chiara

// CREATE playAudio() FUNCTION
function playAudio() {
playcount++; //increase playcount number by 
1
console.log(playcount); 
var button = 
document.getElementById("audiobutton"); 
//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_co 
unt", playcount); 
     };



audio.onended = function() {
if (playcount < 1){
    var button = 
document.getElementById("audiobutton"); 
//grab button id
    button.style.visibility = "visible"; 
//show button again
} else {
            button.style.display = "none"; 
 }
 }; 
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda