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:

  1. 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 the AVPlayerItem to start receiving events.

  2. Serialize and Send Events: Once you receive the events, you can serialize them and send them to your backend analytics server for further analysis.

  3. 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