Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
How can I add a waveform (wavesurfer.js) to my dynamic li tags?

I have an audio player that loads an audio playlist dynamically. Everything works fine except for the waveform. The code goes as follows:

var data1 = [{
          href: "../media/song1.mp3",
          name: "Song 1",
          song: "song1.mp3"
      },{
          href: "../media/song2.mp3",
          name: "Song 2",
          song: "song2.mp3"
      }, {
          href: "../media/song3.mp3",
          name: "Song 3",
          song: "song3.mp3"
      }]

        // Create li elements
        for (var i = 0; i < data1.length; i++) {
            var s = data1[i];
            var t = document.createElement('li');
           t.setAttribute("onclick","myFunction()");
           t.setAttribute("id","li-items");
            
            var wavesurfer = document.createElement('div');
            wavesurfer.setAttribute("id","wave");
            
   
            t.dataset.song = s.song;
            t.textContent = s.name;
            t.appendChild(wavesurfer);

            
            document.getElementById('playlist1').appendChild(t);

}

        
var wavesurfer = WaveSurfer.create({
    container: '#wave',
    waveColor: 'grey',
    height: '45',
    progressColor: 'white'
});

wavesurfer.load(" + data1[i].href + ");

NOTE:(The play pause and other control buttons are in a different js file, so I assume that adding 'wavesurfer.play' at the end may be useless but correct me if I'm wrong.)

Something is missing and I can't quite figure what. Any help would be very much appreciated.

Thanks in advance. :)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda