getByLanguage method

List<ClosedCaptionTrackInfo> getByLanguage(
  1. String language, {
  2. ClosedCaptionFormat? format,
  3. bool autoGenerated = false,
})

Gets all the closed caption tracks in the specified language and format. If autoGenerated is true auto generated tracks are included as well. Returns an empty list of no track is found.

Implementation

List<ClosedCaptionTrackInfo> getByLanguage(
  String language, {
  ClosedCaptionFormat? format,
  bool autoGenerated = false,
}) {
  language = language.toLowerCase();
  return tracks
      .where(
        (e) =>
            (e.language.code.toLowerCase() == language ||
                e.language.name.toLowerCase() == language) &&
            (format == null || e.format == format) &&
            (autoGenerated || !e.isAutoGenerated),
      )
      .toList();
}