Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
El clic del botón evita que se reproduzca un segundo sonido.

Tengo un programa Javascript simple que reproduce un sonido cuando se hace clic en el botón correcto en respuesta a una pregunta. Si el usuario responde una segunda pregunta demasiado rápido y hace clic en una segunda respuesta correcta, el sonido no se reproduce por segunda vez como la primera la reproducción no se ha completado. ¿Necesito desactivar los botones de respuesta mientras dure el sonido? ¿Alguna otra forma de hacerlo? Sugerencias, por favor

Código desaliñado añadido el 27.9.2022

 function setQuestion(){
 // string question 
 var questionText =" x 3 = ";
 questionText=aTimes[index]+ questionText;
 document.getElementById("Question").innerHTML= questionText;
 aAnswers[0]=(aTimes[index]*3);
 aAnswers[1]=Math.floor((Math.random() *10) *(aTimes[index] + 1));
 aAnswers[2]=Math.floor((Math.random() *10) * (aTimes[index] + 2));
 shuffleArray(aAnswers)
 document.getElementById("Answer1").innerHTML= aAnswers[0];
 document.getElementById("Answer2").innerHTML= aAnswers[1];
 document.getElementById("Answer3").innerHTML= aAnswers[2];
 }
 function answerCheck(poss){
 //***************************************************************** 
 //*** does the button clicked match the correct multiple of 3 
 //***************************************************************** 
 if (poss.innerHTML==(aTimes[index]*3) ) {
 changePicture();
 index=(index+1);
 **playAudio();**
 resetButtons();
 setQuestion() ; 
 if (index==10){
 alert("done");
 }
 }
 else{
 alert("not a match");
 poss.style.backgroundColor = "grey"; 
 }
 }
 function resetButtons(){
 document.getElementById("Answer1").style.backgroundColor = "#008CBA" ;
 document.getElementById("Answer2").style.backgroundColor = "#008CBA";
 document.getElementById("Answer3").style.backgroundColor = "#008CBA";
 }
 **function playAudio()** { 
 //************** Play a reward sound 
 var x = document.getElementById("myAudio"); 
 x.play(); 
 } 
 </script>

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

El elemento audio HTML probablemente no encaje bien con lo que quiere hacer aquí. Recomiendo usar una biblioteca como Howler .

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!