Open
Description
What do you want to do with Hls.js?
Is it possible to set the calls to load the manifest to go via a local function rather than having to use a url in the load method? I need to do some other logic to generate the manifest so wanted to use a local function to generate it.
I tried creating my own custom loader and it calls the function but Hls is still calling an XMLHttpRequest for the entire page and parsing that response, and error'ing out on it, rather than using the supplied manifest. I tried copying the example code from the docs but am at a loss. Any help would be greatly appreciated.
What have you tried so far?
const hls = new Hls({
liveSyncDurationCount: 3,
debug: true,
loader: class CustomLoader extends Hls.DefaultConfig.loader {
constructor(config) {
super(config);
var load = this.load.bind(this);
this.load = function(context, config, callbacks) {
if (context.type === 'manifest') {
console.log('Custom loader invoked for manifest');
let manifestData = getCustomManifest();
var onSuccess = callbacks.onSuccess;
callbacks.onSuccess = function(response, stats, context) {
context.responseType = 'text';
response.data = manifestData;
response.url = 'http://localhost/dummy.m3u8';
onSuccess(response, stats, context);
}
load(context, config, callbacks);
} else {
// Fallback for other resource types
load(context, config, callbacks);
}
}
}
}
});
Activity