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

357
Views
Tiene problemas para reproducir audio en "touchstart" y luego pausar audio en "touchend". Estoy usando la biblioteca Howler.JS para hacerlo

Tiene problemas para reproducir audio en "touchstart" y luego pausar audio en "touchend". Estoy usando la biblioteca Howler.JS para hacerlo. Por favor, avíseme si puede ayudar. El objetivo es simplemente reproducir algo de audio cuando el usuario toca en cualquier parte de la pantalla. Luego pausa el audio cuando el usuario levante el dedo. Por el momento, tengo el audio reproduciendo ontouch. Sin embargo, el oyente de pausa no responde. ¿Algunas ideas?

Enlace de Howler JS: https://github.com/goldfire/howler.js

 <script> document.addEventListener("touchstart", function(event) { var sound = new Howl({ src: ['./audio/spray.mp3'], }); sound.play(); }); document.addEventListener("touchend", function(event) { var sound = new Howl({ src: ['./audio/spray.mp3'], }); sound.pause(); sound.currentTime = 0; }); </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ha pasado mucho tiempo sin usar Howler, pero creo que el problema es que las instancias de sonido de Howler son diferentes. Cuando tu lo hagas:

 var sound = new Howl({ src: ['./audio/spray.mp3'], });

Creas una instancia diferente con una ID diferente. Si mal no recuerdo puedes pausar el sonido con el ID o haciendo referencia a la misma instancia.

Por lo tanto, debe mantener una referencia a la instancia de sonido que se está reproduciendo.

about 4 years ago · Juan Pablo Isaza 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!