how do I use analytics with HLS

Generated on 7/31/2024

1 search

To use analytics with HLS (HTTP Live Streaming), you can leverage the new media performance metrics available in iOS 18. Here are the steps and key points to consider:

  1. Client-Side Metrics:

    • You can obtain client-side metrics via access logs, error logs, and various AV player notifications.
    • In iOS 18, these metrics are enhanced and represented as events, providing more data points for HLS streaming assets.
  2. Types of Events:

    • Events include details about the playback session, such as media segment requests, content key requests, playback stalls, and variant switches.
    • These events can be serialized and sent to your backend analytics server for further analysis.
  3. Subscribing to Events:

    • You can subscribe to these events using the AVFoundation API.
    • For Objective-C developers, you would create an AVMetricEventStream instance, set your subscriber, and add the AVPlayerItem. Your subscriber will then start receiving events.
  4. Using the Metrics:

    • The metrics can help triage issues in the field, such as playback taking too long to start or stalling during playback.
    • They provide insights into the workings of AVFoundation APIs, which can be useful for improving performance.
  5. Summary Events:

    • At the end of a playback session, a summary event is created, providing key performance indicators (KPIs) such as token switch count. These KPIs can help monitor media playback health at scale.

For a detailed walkthrough, you can refer to the session Discover media performance metrics in AVFoundation starting at 01:10.

Relevant Sessions

  1. Discover media performance metrics in AVFoundation
  2. Enhance ad experiences with HLS interstitials

These sessions provide comprehensive insights into using analytics with HLS and enhancing ad experiences with HLS interstitials.