removeSubtitle method
根据轨道索引移除字幕。
移除所有匹配指定 trackIndex 的字幕,并返回被移除的字幕列表。
Removes all subtitles matching the given trackIndex
and returns the removed subtitle list.
Implementation
List<Subtitle> removeSubtitle(int trackIndex) {
// 获取待删除的字幕
final toBeRemoved =
subtitles.where((subtitle) => subtitle.index == trackIndex).toList();
// 删除符合条件的字幕
subtitles.removeWhere((subtitle) => subtitle.index == trackIndex);
// 返回被删除的字幕列表
return toBeRemoved;
}