[android]Lyric LRC格式文件解析

Lyric LRC格式文件解析

LRC格式没有多少复杂,因此希望找一个简单易用的程序。不过网上找到的代码不是捆绑了其它的逻辑,封装太差,就是容错太少,因此萌生了自己写一个的念头。

没有找到标准,只有一个 维基简介

项目在 https://github.com/authorfu/LrcParser

1. From a lyric file content to all readable lyric

String lyricString="[00:12.00]Line 1 lyrics\n"+
         "[00:17.20]Line 2 lyrics\n"+
         "[00:21.10]Line 3 lyrics";
BufferedReader reader =new BufferedReader(new StringReader(lyricString));
Lyric lyric;
try{
    lyric=LrcParser.create(reader);
    String[] contents=lyric.findAllContents();
    System.out.println(Arrays.toString(contents));
}catch(IOException e){
    e.printStackTrace();
}

result:

[Line 1 lyrics, Line 2 lyrics, Line 3 lyrics]

2.More info

ArrayList<Sentence> sentences=lyric.findAllSentences(-1,-1);
System.out.println(sentences);

result:

[{index:0|12000(Line 1 lyrics)17199}, {index:1|17200(Line 2 lyrics)21099}, {index:2|21100(Line 3 lyrics)-1}]

Sentence

private long fromTime=-1;// 开始时间
private long toTime=-1;// 结束时间
private String content="";// 歌词
private int index=-1;//第几句歌词

3.ID Tags

ID Tags info can be found by a

HashTable<String,String> tags= lyric.getTags();

4. more useful methods

see

com.github.authorfu.lrcparser.Lyric

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页