Question:
I'm struggling with adding query params to urls. I want to add ?md5=<string>&expires=<number> for each request url (m3u8, ts). I heard fetchSetup would be useful but I didn't see any examples, does anyone know how to solve this problem?
Related issues: https://github.com/video-dev/hls.js/issues/2152, https://github.com/video-dev/hls.js/issues/2142
The docs you linked to contain description and code sample: https://github.com/video-dev/hls.js/blob/master/docs/API.md#fetchsetup
The fetchsetup exposes context that contains the url to be called and the fetch init params.
As detailed in the docs the fetchsetup needs to return a Request object which gets the url and init params, see MDN for details: https://developer.mozilla.org/en-US/docs/Web/API/Request/Request
In your case you will get the context.url and before returning the new request object you can concat your query string params to it.
@OrenMe , I already tried this but nothing happened, so I decided to ask this question:
const hlsConfig = {
fetchSetup: (context, initParams) => {
initParams.credentials = 'include';
return new Request(
context.url + '?md5=test123&expires=test123',
initParams
);
}
}

The library currently only use xhr as default, so either use the xhrSetup or I guess you will need to build your own hls and use the fetch loader.
I know that 1.0.0 will use fetch when possible.
@OrenMe, I found another solution, I guess I don't need authentication for each request, only for .m3u8. Going to close this issue