Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda