how do I enable analytics in HLS
Asked on 07/30/2024
1 search
To enable analytics in HLS (HTTP Live Streaming), you can use the new APIs introduced in iOS 18 for gathering media performance metrics. Here are the steps to enable and utilize these metrics:
-
Subscribe to Events: You need to subscribe to the events you are interested in. This can be done by creating an
AVMetricEventStream
instance and setting your subscriber. Then, add theAVPlayerItem
to start receiving events. -
Serialize and Send Events: Once you receive the events, you can serialize them and send them to your backend analytics server for further analysis.
-
Use Client-Side Metrics: These metrics provide insights into various aspects of media playback, such as startup time, playback stalls, and variant switches. This information can help you triage issues in the field and improve media playback performance.
For a detailed walkthrough, you can refer to the session Discover media performance metrics in AVFoundation.
Relevant Sessions
Chapter Markers
- Discover media performance metrics in AVFoundation
- 0 = Introduction
- 93 = What are events?
- 336 = Subscribing to events

Discover media performance metrics in AVFoundation
Discover how you can monitor, analyze, and improve user experience with the new media performance APIs. Explore how to monitor AVPlayer performance for HLS assets using different AVMetricEvents, and learn how to use these metrics to understand and triage player performance issues.

Enhance ad experiences with HLS interstitials
Explore how HLS Interstitials can help you seamlessly insert advertisements into your HLS content. We’ll also show you how to use integrated timeline to tune your UI experience and build SharePlay for interstitials.