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

251
Visualizações
Howl Js: How to Play the same button after Pause?

I am creating a sound board with a mapped array. I have a onClick Handler which changes the colour of the button that is active/playing and Play/Pauses.

Currently I can pause the 'active' button but cannot restart the track for that button. I can stop playing that track if I press on a different button to play that buttons track.

Just looking for some help on how to Play the same button after I paused it.

Thanks :)

    const handleClick = (beat: string, index: number ) => {

        if (activeIndex === isActive) {
            setIsActive(!isActive);
            activeSound.play();
        }


        if (activeSound) {
            activeSound.stop();           
        } 

        if (!activeSound && activeIndex === isActive) {
            const newSound = createSound(beat);
            newSound.play();
            setActiveSound(newSound);
        }

        if (activeIndex !== index) {
            const newSound = createSound(beat);
            newSound.play();
            setActiveSound(newSound);
        }
        setActiveIndex(index);
    }
    return (
        <Container>
            <Title> Melody </Title>
            <Grid>
                {
                    melodyData.map((beat, index: number) => {
                        return <Button key={index} $isActive={activeIndex === index} onClick={() => handleClick(beat.src, index)}>{beat.title}</Button>
                    })
                }
            </Grid>
        </Container>
    )
};
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