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

226
Vistas
Multiple wavesurfer.js players

When I have more than 1 instance on a single page the player doesn't work properly, I figured I'd have to create a foreach cicle of some sorts, if anyone could help me with this issue it would be much appreciated.

Here's what I have:

<script src='https://unpkg.com/wavesurfer.js'></script>
<script>
  duration = document.querySelector('#duration');
current = document.querySelector('#current');
playPause = document.querySelector('#playPause');
var timeCalculator = function (value) {
    second = Math.floor(value % 60);
    minute = Math.floor((value / 60) % 60);
    if (second < 10) {
        second = '0' + second;
    }
    return minute + ':' + second;
};

wavesurfer = WaveSurfer.create({
    container: '#wave',
    waveColor: '#a43152',
    progressColor: '#5b1b2d',
    height: 30,
    barRadius: 2,
    barWidth:3,
    barGap:2,
    scrollParent: false
});

wavesurfer.load('files/$title.mp3');

playPause.addEventListener('click', function (e) {
    wavesurfer.playPause();
});

wavesurfer.on('ready', function (e) {
    duration.textContent = timeCalculator(wavesurfer.getDuration());
});

wavesurfer.on('audioprocess', function (e) {
    current.textContent = timeCalculator(wavesurfer.getCurrentTime());
});

wavesurfer.on('play', function (e) {
    playPause.classList.remove('fi-rr-play');
    playPause.classList.add('fi-rr-pause');
});

//change pause button to play on pause
wavesurfer.on('pause', function (e) {
    playPause.classList.add('fi-rr-play');
    playPause.classList.remove('fi-rr-pause');
});

wavesurfer.on('seek', function (e) {
    current.textContent = timeCalculator(wavesurfer.getCurrentTime());
});
</script>";
        
    
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