checkAllChaptersLoadedOrError() {
    const chapters = this.getChapters(),
          readyChapters = chapters.filter(({isLoaded}) => isLoaded);
    if (chapters.length === chapters.filter(({isLoaded, isError}) => isLoaded || isError).length) {
      // no chapters OR all chapters loaded or quit loading with error
      if (readyChapters.length === 0) {
        // no chapters -> remove chapters button
        this.chaptersButton.remove();
      } else {
        // try to find a chapter track in the language set in `options.chaptersLanguage`
        let langChapter = readyChapters.find(({srclang}) => srclang === this.options.chaptersLanguage);
        // if none was found try to find one using the current player language
        langChapter = langChapter || readyChapters.find(({srclang}) => srclang === i18n.lang);

        if (readyChapters.length === 1 || !langChapter) {
          // use first chapter track if only one exists or no chapter with the correct lanmguage was loaded
          this.drawChapters(readyChapters[0].trackId);
        } else {
          // use the chapter with the correct language
          this.drawChapters(langChapter.trackId);
        }
      }
    }
  }
Once all chapters are loaded, determine which chapter file should be displayed as the chapters menu.