setupSubtitleSource method

Future<void> setupSubtitleSource(
  1. BetterPlayerSubtitlesSource 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(BetterPlayerSubtitlesSource subtitlesSource,
    {bool sourceInitialize = false}) async {
  _betterPlayerSubtitlesSource = subtitlesSource;
  subtitlesLines.clear();
  _asmsSegmentsLoaded.clear();
  _asmsSegmentsLoading = false;

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

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