-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
muxinc/media-elements
#167Description
I am trying to use the config property in ReactPlayer to apply custom HLS settings, specifically the xhrSetup function, to append a token to the stream URL and set custom headers. However, it seems that the config is not being applied, and the xhrSetup function is never triggered.
Steps to Reproduce:
Use ReactPlayer with an HLS stream (.m3u8 URL).
Pass a config object with an hls configuration, including an xhrSetup function.
Observe that the xhrSetup function is not called, and the custom headers or URL modifications are not applied.
import ReactPlayer from 'react-player';
const streamToken = 'my-stream-token';
const src = 'https://example.com/stream.m3u8';
const config = {
hls: {
xhrSetup: (xhr, url) => {
console.log('XHR Setup for URL:', url);
const urlWithToken = `${url}${url.includes('?') ? '&' : '?'}token=${encodeURIComponent(streamToken)}`;
xhr.open('GET', urlWithToken, true);
xhr.setRequestHeader('Authorization', `Bearer ${streamToken}`);
xhr.withCredentials = true;
},
debug: true,
},
};
<ReactPlayer
url={src}
playing
config={config}
/>;
fteotini, AdrianoDiDio and Neklof
Metadata
Metadata
Assignees
Labels
No labels