Chapters

The Flowplayer Native chapters plugin (chapters) reads chapters from a WebVTT file and displays them on the player timeline:

  • The timeline is divided into chapter segments.
  • Hovering a segment shows the chapter title.
  • The title of the current chapter is shown above the control bar.

Chapters

Chapters plugin prerequisites

  • A WebVTT file with chapter cues. The text of each cue is used as the chapter title.
  • A video with a finite duration. Chapters are not displayed for livestreams.

Example chapters file:

WEBVTT

00:00:00.000 --> 00:01:30.000
Introduction

00:01:30.000 --> 00:05:00.000
Main part

00:05:00.000 --> 00:06:10.000
Summary

OVP hosted videos

Chapters for OVP hosted videos are created with the VTT editor in the platform, see chapters and subtitles. OVP cloud embeds display these chapters automatically, so a separate installation or configuration is not required.

Chapters plugin installation

Load the plugin next to the core player:

<script src="//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/hls.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/chapters.min.js"></script>

Player and plugins exist in different release versions. Please see the release channel documentation.

Chapters plugin configuration

Configure the chapters file with the top-level configuration option chapters:

    • property
    • description
    • src string
    • URL of the WebVTT chapters file.
    • lang string
    • Optional language of the chapters track.

chapters also accepts an array of these objects. In this case only the first entry is used.

Example

flowplayer("#player_container", {
  src: "https://some.domain.com/pathto/media.m3u8",
  chapters: {
    src: "https://some.domain.com/pathto/chapters.vtt"
  }
})

When you load a new video with setSrc(), the chapters of the previous video are removed. To add chapters for the new video, pass the chapters option with setOpts():

player.setSrc("https://some.domain.com/pathto/other-media.m3u8")
player.setOpts({ chapters: { src: "https://some.domain.com/pathto/other-chapters.vtt" } })

Chapters plugin API

The plugin API is available as player.chapters.

    • property / method
    • description
    • chapters
    • Array of the loaded chapters. Each chapter has the properties start and end (in seconds) and label (the chapter title).
    • current()
    • Returns the current chapter, or undefined if playback is not inside a chapter.
    • jump(index)
    • Seeks to the start of the chapter at index in the chapters array.

Example

const player = flowplayer("#player_container", {
  src: "https://some.domain.com/pathto/media.m3u8",
  chapters: { src: "https://some.domain.com/pathto/chapters.vtt" }
})

// jump to the second chapter
document.querySelector("#chapter-2").addEventListener("click", function () {
  player.chapters.jump(1)
})

Styling

The plugin uses the following CSS classes:

    • class
    • description
    • .has-chapters
    • Added to the player root element while chapters are displayed.
    • .fp-chapter
    • A chapter segment on the timeline.
    • .fp-chapter-info
    • The element showing the title of the current chapter above the control bar.
Results