I'm currently trying to use the HTML video player to stream a file from the file system in Electron.
I would like to start streaming as the file is downloading.
I'm not sure if my current plan will work (or if this is even possible).
The plan
- Create a readble stream from the file that updates as the file is downloaded
- Generate a blob url from that stream
- Use that blob url as the video source
Where I think this is currently failing is that I generate a blob url after the first chunk is read, but any chunks after that aren't included in the blob url.
This is about what I would like to do (I know this code will not work)
const file = GrowingFile.open(downloadPath) // provides a readable stream for a file
let chunks = [];
file.on('data', (chunk) => {
chunks.push(chunk);
const blob = new Blob(chunks);
const url = URL.createObjectURL(blob);
video.src = url // continuously update the video src with a new blob url
})
My main question is:
Is there a way to push to a blob list after a url has been generated from it and continue to use the same blob url?
file://
protocol directly does not work or you want some kind of work in your data? – Calvinfile://
only works if the file is completely downloaded. I need to request it right when something is written so I can begin streaming as soon as possible. – Undies