1—Read file xx.mp3
2—Play the sound and get the current playtime (milliseconds): time_ms
3—Read external file: xx.lrc
——Reading the LRC file is a simple step, as is the way to read plain text files.
——The read LRC data is split by line (“/ n” is a newline character), and each element of the array represents one line of LRC content.
—Simple regular expression application or string fetching substring operation
—Separates strings by delimiters
——The time and lyrics of each line are extracted from the array, and the time string is converted into computer readable time (mm * 60 + ss. ff) milliseconds to solve the problem of time series.
4.Finally, with the music playing, read the lyrics in the playtime period. Compare the current playtime time_ms with the time in LRCarray (array or structure).
If equal, it shows the lyrics in LRCarray.