I am currently creating an app that plays music. I would like to add a feature that shows the music lyrics while the music plays, with the current position of the text marke
The standard way to do this is using the kar file extension as suggested by the other answer. Here are some more details.
The .kar extension just signifies that a standard midi file contains lyric information. To build your karaoke player you need to do two things: play the instrument part of the midi file and display the lyrics.
This can be achieved in two ways. Either you could use the built in MusicPlayer to play the midi file and then access the lyric information from a virtual endpoint: here
You would need to access midi meta messages with codes 0x01 (text) or 0x05 (lyric). These messages store the lyric data as a series of hex numbers where each hex number represents an ascii character.
This approach allows you to play the MIDI file and access the lyrics. The problem is that you need to be able to display the lyrics ahead of time so the user can read them before they're played.
To do this you could parse the midi file manually: here
You would need to loop over the MIDI file and extract the text lyrics with their time stamps. Then you could display a section of lyrics ahead of time and change the colour or do a bouncing ball effect as the lyrics became due.