hlsjs-ipfs-loader
hlsjs-ipfs-loader copied to clipboard
JS IPFS instance supplied via hls.config prevents Hls.js from kicking off its demuxing web worker
By default, Hls.js delegates the demuxing work to a web worker and the Hls.js config is included in the payload sent to that web worker.
Error is thrown when JSON.stringify tries to "stringify" circular structure inside the JS IPFS instance. Hls.js then reverts to inline demuxing as a fallback solution. This is not ideal.
A viable solution is to inject the IPFS instance to the IPFS loader class via a factory function (that accepts the IPFS instance as an augment and supplies it to the loader class returned).
For instance,
function HlsjsIPFSLoaderFactory (ipfs) {
return class HlsjsIPFSLoader {...}
}
Then to use it:
const ipfs = await Ipfs.create();
Hls.DefaultConfig.loader = IPFSLoaderFactory(ipfs);