fix: 字幕查询越界

This commit is contained in:
guozhigq
2024-07-01 23:11:11 +08:00
parent 2cc43fad57
commit 0d96327f34

View File

@ -17,7 +17,11 @@ class PlDanmakuController {
int segCount = (videoDuration / segmentLength).ceil();
requestedSeg = List<bool>.generate(segCount, (index) => false);
}
try {
queryDanmaku(calcSegment(progress));
} catch (e) {
print(e);
}
}
void dispose() {
@ -31,6 +35,7 @@ class PlDanmakuController {
void queryDanmaku(int segmentIndex) async {
assert(requestedSeg[segmentIndex] == false);
if (requestedSeg.length > segmentIndex) {
requestedSeg[segmentIndex] = true;
final DmSegMobileReply result = await DanmakaHttp.queryDanmaku(
cid: cid, segmentIndex: segmentIndex + 1);
@ -44,6 +49,7 @@ class PlDanmakuController {
}
}
}
}
List<DanmakuElem>? getCurrentDanmaku(int progress) {
int segmentIndex = calcSegment(progress);