How to load a video from binary data?

I’m trying to figure out how this would work, say with an mp4 file. If anyone happens to have an example, please let me know. Unless I’m reading it wrong, it seems you’d always have to get the video back into a File in order to load it into the VideoComponent. I’d love to be able to load it directly from binary data.

I don’t think you can, the VideoComponent just uses whatever facilities are available from the operating system to show a video in a window. I would assume those will typically use a file on disk as the media source.

Ok thanks for the info! In that case, if anyone is trying to do this in the future, this is my hacky workaround to put the video back into a file in a random location, then load it directly from the file. For us, since this will be an audio plugin, I’ll use somewhere in the library folder where we also store settings and other items. Here I just use the desktop as a quick test.

File temp = File("~/Desktop/whatever.mp4");
temp.replaceWithData(BinaryData::TAILS_mp4, BinaryData::TAILS_mp4Size);
videoComp.load(temp);
addAndMakeVisible(videoComp);

1 Like

Why not just have your installer place the file in a place you expect it? Seems a bit crazy to embed the file in the binary in order to write that file to disk; you can skip that step entirely if the installer puts the file in a known place for you.

Definitely an option but oddly in our situation it might be easier to just do it manually. No disagreement that it’s back-assward :wink: Cheers.

1 Like