Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,12 @@ Full list of Events is available below:

You can use the internal loader definition for your own implementation via the static getter `Hls.DefaultConfig.loader`.

There are three configuration options that define which loader class(es) HLS.js will use. Set one or more of these to a custom loader to enable custom network handling:

- `pLoader` when defined, handles HLS playlist.
- `fLoader` when defined, handles fragments (segments and parts).
- `loader` handles everything by default becuase `pLoader` and `fLoader` are undefined. It always handles CMCD, Content-Steering, clear AES key loading, and HLS interstitial asset lists.

Example:

```js
Expand Down Expand Up @@ -2338,6 +2344,30 @@ let myHls = new Hls({
});
```


### Response filtering

This example leaves the request and loading stats to HLS.js, and replaces the response data for a particular type:

```js
class ResponseFilterLoader extends Hls.DefaultConfig.loader {
load(context, config, callbacks) {
const { type, url } = context;
// if this type of request requires response filtering then do it in `onSuccess`:
if (type === typeToFilter) {
const complete = callbacks.onSuccess; // capture original callback
callbacks.onSuccess = (loaderResponse, stats, successContext, networkDetails) => {
// Do something with loaderResponse.data:
loaderResponse.data = doFilter(loaderResponse.data);
// Pass the new result to the original onSuccess callback:
complete(loaderResponse, stats, successContext, networkDetails);
};
}
super.load(context, config, callbacks);
}
}
```

## Errors

Full list of errors is described below:
Expand Down
Loading