Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!