parseLines method
call this method parse
Implementation
@override
List<LyricsLineModel> parseLines({bool isMain: true}) {
lyric =
RegExp(r"""LyricContent="([\s\S]*)">""").firstMatch(lyric)?.group(1) ??
lyric;
//读每一行
var lines = lyric.split("\n");
if (lines.isEmpty) {
LyricsLog.logD("未解析到歌词");
return [];
}
List<LyricsLineModel> lineList = [];
lines.forEach((line) {
//匹配time
var time = advancedPattern.stringMatch(line);
if (time == null) {
//没有匹配到直接返回
//TODO 歌曲相关信息暂不处理
LyricsLog.logD("忽略未匹配到Time:$line");
return;
}
//转时间戳
var ts = int.parse(
advancedValuePattern.firstMatch(time)?.group(1)?.split(",")[0] ??
"0");
//移除time,拿到真实歌词
var realLyrics = line.replaceFirst(advancedPattern, "");
LyricsLog.logD("匹配time:$time($ts) 真实歌词:$realLyrics");
List<LyricSpanInfo> spanList = getSpanList(realLyrics);
var lineModel = LyricsLineModel()
..mainText = realLyrics.replaceAll(qrcPattern, "")
..startTime = ts
..spanList = spanList;
lineList.add(lineModel);
});
return lineList;
}