How do i get hls metrics

Generated on 7/31/2024

1 search

To get HLS metrics, you can utilize the enhanced client-side metrics available in iOS 18 for HLS streaming assets. These metrics are represented as events, and you can subscribe to these events to gather detailed information about media playback. Here are the steps to obtain HLS metrics:

  1. Access Logs and Notifications: Previously, you could obtain some client-side metrics via access logs, error logs, and various AV player notifications.

  2. Enhanced Metrics in iOS 18: In iOS 18, the metrics for HLS streaming assets have been enhanced, providing more data points. These metrics are represented as events, which include:

    • Playlist Events: Information about fetching the multivariate playlist, video, audio, and subtitle playlists.
    • Media Segment Events: Details about fetching media segments and content keys.
    • Playback Events: Events like "likely to keep up" indicating when the player has buffered enough to resume playback.
    • Stall and Variant Switch Events: Information about playback stalls and variant switches.
    • Summary Events: Key performance indicators (KPIs) at the end of a session, such as token switch count.
  3. Subscribing to Events: You can subscribe to these events using the AVFoundation APIs. For Objective-C developers, you would create an AVMetricEventStream instance, set your subscriber, and add the AVPlayerItem. Your subscriber will start receiving events, which you can serialize and send to your backend analytics server.

For a detailed walkthrough, you can refer to the session Discover media performance metrics in AVFoundation starting at the "What are events?" chapter.

Relevant Sessions