google / google/ExoPlayer

Add Downloader analytics listeners (e.g., onLoadCompleted / onLoadError)

Open
#7,652 0 comments 0 reactions 1 assignee Assigned to @marcbaechinger View on GitHub
enhancement
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

As many other people we are often the victim of misconfigured CDNs, overloaded CDNs or problems with origin. Its for this reason we like to track when segments fail (or even manifest) to download and include information such as response headers, status codes, uris. This is possible for an online streaming session (MediaSourceEventListener / AnalyticsListener) but not during download for an offline playback session.

### Proposed solution
Add:
`com.google.android.exoplayer2.offline.DownloadManager#addDownloadAnalyticsListener`

```
public interface DownloadAnalyticsListener {

default void onLoadError(DownloadManager downloadManager, Download download, int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException error, boolean wasCanceled) { }

default void onLoadStarted(DownloadManager downloadManager, Download download, int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) { }

default void onLoadCompleted(DownloadManager downloadManager, Download download, int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) { }

}
```

### Alternatives considered
We have considered using an OKHttpDatasourceFactory with TransferListener to mitigate this need.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.