indigo-player icon indicating copy to clipboard operation
indigo-player copied to clipboard

Setup to leverage HLS.js API

Open psuru opened this issue 6 years ago • 3 comments

Thanks for building amazing player.This is not issue Just a question. Is there any way to leverage HLS.js API through indigo player? I want to do some xhrsetup for my video. If it is possible then 2 question arises , first how can I do that and second is what happens on ios devices, because hls.js is not needed on ios devices for your player.

psuru avatar Oct 15 '19 06:10 psuru

At the moment, there is no possibility to alter the config before it gets used to initialize HLS.js.

It seems adding a HLSJS_PREPARE event would make sense, the event data would contain a reference to the config (which you can then use to alter). It's basically the same logic as exposing the Shaka instance with the SHAKA_INSTANCE event, although I haven't provided this functionality for HLS.js (exposing both the instance and the ability to change the HLS.js config before the HLS.js instance is created).

Would something like this work for you?

player.on(IndigoPlayer.Events.HLSJS_PREPARE, ({ config }) => {
  config.xhrSetup = xhr => {
    xhr.withCredentials = true;
  };
});

For iOS, indigo-player does not select HLS.js but uses the native HTML5 video element (which supports native HLS playback for both iOS & Safari).

Could you explain me your usecase more in detail? I can then better assist if any changes have to be made to the native HLS media module.

matvp91 avatar Oct 15 '19 17:10 matvp91

I want to replace url before requesting something like this, var config = { xhrSetup: function(xhr, url) { // Need to replace URL url = url.replace('http//', 'https://'); xhr.open('GET', url, true); } Same issue opened Here

psuru avatar Oct 16 '19 03:10 psuru

Ok, thank you for the info. I'd be happy to accept a PR with the implementation described above if you need it real quick. If not, I'll provide a PR somewhere this weekend.

matvp91 avatar Oct 18 '19 12:10 matvp91