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

411
Visualizações
why does my player play the songs by themselves (wavesurfer.js)

i want to show the sound waves from my music player all the time but every time i try the music plays by itself

here is a part of my code, I'm using the lib wavsurfer.js

ps: I'm calling the generateWaveform function in ngOnInit for the sound waves to appear when the application starts

      new Promise((resolve): void => {
          this.wave = WaveSurfer.create({
              container: '#waveform',
              waveColor: this.artist.primaryColor,
              progressColor: 'dark',
              height: 16,
          });

          this.wave.on('ready', () => {
              this.wave.play();
          });
        this.cd.detectChanges();

          this.wave.load(this.music);

          resolve(null); 

      });
  }

  onPreviewPressed(): void {
      this.changeButton('play');
      if (!this.wave) {
          this.generateWaveform();
      }

      this.cd.detectChanges();

      this.wave.load(this.music); 

      new Promise((resolve, reject) => this.wave.load(this.music));

  }

  changeButton(chave: String) {
      setTimeout(() => {
          if (chave === 'play') {
              this.handlePlay();
          } else {
              this.handlePause();
          }
      }, 100);
  }
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