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

144
Views
Reproducir sonidos HTML repetidamente en dispositivos móviles tiene un comportamiento extraño

Tengo un programa js que hace que los sonidos se reproduzcan repetidamente a través de un temporizador y funciona perfectamente bien en mi computadora, sin embargo, no funciona cuando trato de usarlo en mi teléfono (iPhone 13) o tableta (iPad air 4). El sonido llega tarde o no se reproduce en absoluto. Si proporciona alguna pista, también noté que si cambio el volumen del sistema del teléfono (con los botones físicos en el costado del teléfono) mientras el programa se está ejecutando, la barra de volumen se retrasa y salta en lugar de aumentar o disminuir suavemente.

Configuración para permitir que los sonidos se reproduzcan en ios (ya que necesitan la interacción del usuario)

 var click1 = new Audio('../audio/click1.mp3'); click1.preload = "auto"; enterBtn.addEventListener('click', () => { //...code click1.volume = 0; click1.play(); click1.pause(); click1.currentTime = 0; click1.volume = 1; });

El código que se ejecuta cuando es llamado por un temporizador

 function playClick() { click1.load(); click1.play(); click1.currentTime = 0; //...code }

Código de temporizador que tomé del desbordamiento de pila

 function Timer(callback, timeInterval, options) { this.timeInterval = timeInterval; this.start = () => { this.expected = Date.now() + this.timeInterval; this.theTimeout = null; if (options.immediate) { callback(); } this.timeout = setTimeout(this.round, this.timeInterval); console.log('Timer Started'); } this.stop = () => { clearTimeout(this.timeout); } this.round = () => { var drift = Date.now() - this.expected; if (drift > this.timeInterval) { if (options.errorCallback) { options.errorCallback(); } } callback(); this.expected += this.timeInterval; this.timeout = setTimeout(this.round, Math.max(0,this.timeInterval - drift)); } } export default Timer;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Qué pasa con el uso de setInterval en lugar de un temporizador? https://developer.mozilla.org/en-US/docs/Web/API/setInterval

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!