In this project, we developed a lyric player using React. We converted lrc files to JSON and used this data to display lyrics synchronously with the audio. Users can click on any word to get its definition, and we used React's useRef hook to manage the audio player's current time. We made this project highly interactive with the use of a scoreboard and a definition modal.
An LRC file is a format that synchronizes song lyrics with an audio file. It is often used in karaoke to display the lyrics as the audio plays.
Converting an lrc file to JSON is a simple way of making the lrc file data more usable in our React application. JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy to read and write for humans and easy to parse and generate for machines. Since we intend to upload our song information on Firebase Realtime DB, which is highly compatible with JSON, we convert the lrc file to JSON format.
The useRef hook in React is used to access the properties of a component. In this project, we are using it to access the audio player's current time and use that time to highlight the current line of lyrics.
src attribute or the source element. Here we're adding controls to it, and listening to events like 'onTimeUpdate' and 'onEnded' to manage the display of the lyrics and other interactive components.