In the past, you could use URL.createObjectURL()
and pass it a MediaStream. However, this has been removed (see https://www.fxsitecompat.dev/en-CA/docs/2017/url-createobjecturl-stream-has-been-deprecated/).
The replacement functionality was to instead use HTMLMediaElement.srcObject
. This does a good job of covering the video case.
However, HTMLImageElement
does not inherit from HTMLMediaElement
. It does not have srcObject, either.
In my specific case, I am developing a FireFox plugin that utilizes the WebRequest filter stream functionality to do image transformations. With that API I get ArrayBuffer chunks of data. I would like to be able to stream these as I receive them to an Image()
that is decoding them on the fly rather than simply accumulating them, turning them into a Blob, and then converting into a URL via URL.createObjectURL(blob)
.
Is there a way I can accomplish this in a streaming fashion?
(Note 1: I'm ok with a FireFox specific solution if need be.)
(Note 2: I tried setting HTMLVideoElement
src to e.g. PNG but it appears that the video element is indeed picky and only supports video formats rather than stills. If I could get HTMLVideoElement.srcObject
to load image stills, that might make a MediaStream-based solution possible, too).