setupSubtitleSource method

Future<void> setupSubtitleSource(
  1. PlayerKidSubtitlesSource subtitlesSource, {
  2. bool sourceInitialize = false,
})

Setup subtitles to be displayed from given subtitle source. If subtitles source is segmented then don't load videos at start. Videos will load with just in time policy.

Implementation

Future<void> setupSubtitleSource(PlayerKidSubtitlesSource subtitlesSource,
    {bool sourceInitialize = false}) async {
  betterPlayerSubtitlesSource = subtitlesSource;
  subtitlesLines.clear();
  _asmsSegmentsLoaded.clear();
  _asmsSegmentsLoading = false;

  if (subtitlesSource.type != PlayerKidSubtitlesSourceType.none) {
    if (subtitlesSource.asmsIsSegmented == true) {
      return;
    }
    final subtitlesParsed =
        await PlayerKidSubtitlesFactory.parseSubtitles(subtitlesSource);
    subtitlesLines.addAll(subtitlesParsed);
  }

  // _postEvent(BetterPlayerEvent(BetterPlayerEventType.changedSubtitles));
  // if (!_disposed && !sourceInitialize) {
  //   _postControllerEvent(BetterPlayerControllerEvent.changeSubtitles);
  // }
}