-
What version of Hls.js are you using?latest What browser (including version) are you using?chrome What OS (including version) are you using?macOS Test streamhttps://test-streams.mux.dev/x36xhzz/url_8/193039199_mp4_h264_aac_fhd_7.m3u8 Configurationclass fLoader extends Hls.DefaultConfig.loader {
constructor(config) {
super(config);
var load = this.load.bind(this);
this.load = function (context, config, callbacks) {
var onSuccess = callbacks.onSuccess;
callbacks.onSuccess = function (response, stats, context) {
console.warn(`byteLength ${response.data.byteLength}`)
onSuccess(response, stats, context);
};
load(context, config, callbacks);
};
}
}
var hls = new Hls({
fLoader,
}); Additional player setup stepsNo response Checklist
Steps to reproduce
Expected behaviourresponse.data.byteLength is > 0 What actually happened?response.data.byteLength == 0 Console outputbyteLength 0 Chrome media internals outputNo response |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
is this reason? https://developer.mozilla.org/en-US/docs/Glossary/Transferable_objects |
Beta Was this translation helpful? Give feedback.
-
I think @hzm18, you are right. The ArrayBuffer detaches when the data is passed to the worker. if (worker) {
// post fragment payload as transferable objects for ArrayBuffer (no copy)
worker.postMessage(
{
cmd: 'demux',
data,
decryptdata,
chunkMeta,
state,
},
data instanceof ArrayBuffer ? [data] : []
);
} Setting the |
Beta Was this translation helpful? Give feedback.
-
@jungdaniel Could you
Could you show me how to "making a copy of the data in the onProgress callback"? |
Beta Was this translation helpful? Give feedback.
-
I haven't tried this, and probably you would need to tweak it to make this work. The idea was to make a copy with class fLoader extends Hls.DefaultConfig.loader {
constructor(config) {
super(config);
const load = this.load.bind(this);
this.load = function (context, config, callbacks) {
const { onProgress, onSuccess } = callbacks;
callbacks.onProgress = function(stats, context, data, networkDetails) {
// By copying I ment something like this:
const modifiedData = data instanceof ArrayBuffer ? data.slice(0) : data;
// Not sure if return is necessary
return onProgress(stats, context, modifiedData, networkDetails);
},
callbacks.onSuccess = function (response, stats, context) {
// do something with response.data
onSuccess(response, stats, context);
};
load(context, config, callbacks);
}
}
const hls = new Hls({ fLoader }); BTW I think this is hacky and performance-wise not a good solution. For my use-case I could use an event for accessing data I wanted to use. It was either |
Beta Was this translation helpful? Give feedback.
-
ok, thank you very much. |
Beta Was this translation helpful? Give feedback.
is this reason? https://developer.mozilla.org/en-US/docs/Glossary/Transferable_objects