getSubtitles method

  1. @override
Future<Subtitles> getSubtitles()
override

Implementation

@override
Future<Subtitles> getSubtitles() async {
  var subtitlesContent = subtitleController.subtitlesContent;
  final subtitleUrl = subtitleController.subtitleUrl;

  // If the subtitle content parameter is empty we will load the subtitle from the specified url.
  if (subtitlesContent == null && subtitleUrl != null) {
    // Lets load the subtitle content from the url.
    subtitlesContent = await loadRemoteSubtitleContent(
      subtitleUrl: subtitleUrl,
    );
  }
  // Tries parsing the subtitle data
  // Lets try to parse the subtitle content with the specified subtitle type
  if (subtitlesContent != null) {
    return getSubtitlesData(
      subtitlesContent,
      subtitleController.subtitleType,
    );
  }

  return Subtitles(subtitles: []);
}