Moriafly / LyricViewX

LyricViewX is a beautiful Lyrics View for Android.
GNU General Public License v3.0
82 stars 12 forks source link

How to use your library with lrc file? #2

Closed maxakash closed 3 years ago

maxakash commented 3 years ago

There is no documentation to add lyric view in layout. Please help me with that.

Moriafly commented 3 years ago

Layout:

<com.dirror.lyricviewx.LyricViewX
    android:id="@+id/lyricViewX"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:lrcPadding="16dp">
</com.dirror.lyricviewx.LyricViewX>

In the Activity:

val file = File("...") // lrc file path
lyricViewX.loadLyric(file)
Moriafly commented 3 years ago

There are many ways to get the lyrics to a song, you can get the text of the lyrics in other ways and pass it to LyricViewX.

  1. Get the LRC file of the song name. It can be read either directly into a File or as a stream, usually encoded in UTF-8.
  2. Get inline lyrics of the song, such as ID3v2 lyrics tag of MP3 files, through some open source libraries (like mp3agic or jaudiotag)
  3. Get online lyrics.The String retrieved can be accessed directly through lyricViewx.loadLyric (String).
maxakash commented 3 years ago

Ok got it, I used an input stream to convert the file to string. It works perfectly but throws an excpetion which I have mentioned in another issue.