Skip to content

ReactPlayer config for hls.js is not applied (xhrSetup not triggered) #2015

@jheanlee

Description

@jheanlee

The issue is supposed to have been resolved in #1977 , but it does not seem to be the case.

I am trying to set a custom xhrSetup() in the hls.js config. Yet, the function does not seem to be called.
Tested on versions 3.3.3 and 3.4.0.

Steps to reproduce:

  1. Use <ReactPlayer /> with a .m3u8 HLS stream url.
  2. Pass a config object with a xhrSetup() to the player.
  3. Notice that the console.log() is not printed and the headers are not changed.

Example:

import ReactPlayer from "react-player";

function App() {
  const config = {
    hls: {
      xhrSetup: (xhr: XMLHttpRequest, url: string) => {
        console.log("xhr setup");
        xhr.setRequestHeader("example_header", "value");
      },
      debug: true,
    },
  };
  return (
    <>
      <ReactPlayer
        controls
        config={config}
        src="https://stream.mux.com/VcmKA6aqzIzlg3MayLJDnbF55kX00mds028Z65QxvBYaA.m3u8"/>
    </>
  )
}

export default App;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions