Add chapter markers to enable users to quickly navigate your content.
Chapter markers enable users to quickly navigate your content.
AVPlayer in tvOS and macOS automatically presents a chapter-selection interface if markers are found in the currently played asset. You can also directly retrieve this data whenever you want to create your own custom chapter-selection interface.
Retrieve the Timed Metadata
Chapter markers are a type of timed metadata that apply only to ranges of time within the asset’s timeline. You retrieve an asset’s chapter metadata using either the
chapter methods. These methods become callable without blocking after you asynchronously load the value of the asset’s
Convert Timed Metadata into Chapter Data
The value returned from these methods is an array of
AVTimed objects, each representing an individual chapter marker. An
AVTimed object is composed of a
CMTime, defining the time range to which its metadata applies, an array of
AVMetadata objects representing the chapter’s title, and optionally, its thumbnail image. The following example shows how to convert the
AVTimed data into an array of custom model objects, called Chapter, to be presented in the app’s view layer.
With the relevant data converted, you can build a chapter-selection interface and use the time value of the chapter object to seek the current presentation using the player’s