parseLines method
call this method parse
Implementation
@override
List<LyricsLineModel> parseLines({bool isMain: true}) {
//读每一行
var lines = lyric.split("\n");
if (lines.isEmpty) {
LyricsLog.logD("未解析到歌词");
return [];
}
List<LyricsLineModel> lineList = [];
lines.forEach((line) {
//匹配time
var time = pattern.stringMatch(line);
if (time == null) {
//没有匹配到直接返回
//TODO 歌曲相关信息暂不处理
LyricsLog.logD("忽略未匹配到Time:$line");
return;
}
//移除time,拿到真实歌词
var realLyrics = line.replaceFirst(pattern, "");
//转时间戳
var ts = timeTagToTS(time);
LyricsLog.logD("匹配time:$time($ts) 真实歌词:$realLyrics");
var lineModel = LyricsLineModel()..startTime = ts;
if (realLyrics == "//") {
LyricsLog.logD("移除无效字符://");
realLyrics = "";
}
if (isMain) {
lineModel.mainText = realLyrics;
} else {
lineModel.extText = realLyrics;
}
lineList.add(lineModel);
});
return lineList;
}