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

190
Visualizações
Playing mp3 using external button in the react-audio-player

I tried to play an audio file with a react-audio-player using the external button. i go through its documentation and find that I can do it by creating a reference of an audio component and call play event from my external button but somehow I faced the error.

Package name - react-audio-player

Code

import ReactAudioPlayer from 'react-audio-player';

render()
{
return(
{songs ?
                            songs.map((song, index) =>
                            (
                                <tr key={index}>
                                    <td><img className="rounded-all img-circle" src={song.cover} alt="playlist cover" /></td>
                                    <td>{song.name}</td>
                                    <td>{song.gener}</td>
                                    <td className="d-flex justify-content-end">
                                        <ReactAudioPlayer
                                            src={song.song_mp3}
                                            ref={(element) => { this.rap = element; }}
                                        />
                                        <i className="fa fa-play-circle d-flex align-items-center mgr-2 text-white play-button" onClick={this.rap.onPlay}></i>
                                    </td>
                                </tr>
                            ))
                            : null}
))

TypeError: Cannot read properties of undefined (reading 'onPlay')

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