Movie from memoryblock

Can anyone tell me how to convert a memoryblock that’s arrived through a tcpsocket into a movieplayer’s content? In other words, what’s the syntax for converting a memoryblock to a movie?

Thank you.

Mac? Win? Linux? Web? iOS?

ah, just write to file and open as movie.

If you receive the full file in a memoryblock then write it to the filesystem using BinaryStream.
You might load the written file into a movieplayer.

I should have clarified…

Windows 10, btw. I don’t need to write the movie to a folderitem. I want to display it in a movieplayer. If all it does is play in the movieplayer, nothing else needs to be done. If it gets replaced, the replacement video gets sent back to the server over tcpsocket for storage.

Christian, I think that’s what your openMovieFromMemoryBlockMBS function did/does but I believe the Quicktime plugin no longer applies…?

Reading through the documentation it sounds like that’s what you’re going to need to do.
The Movie class does not let you create an instance from a MemoryBlock.
http://documentation.xojo.com/index.php/Movie

Thank you, gentlemen. If I don’t hear otherwise, I’ll assume I have to accept the overhead of writing to the filesystem and then reading back into a movieplayer.

Its an unfortunate amount of disk churning. I have to write the folderitem to disk, read it back into the movie player and then delete it from disk. Ugh!

If you use SpecialFolder.Temporary you shouldn’t have to manage the deletion, it’ll get cleaned up automatically at some point™

That’s clever, Tim. Thank you. Do you know what triggers the automatic deletion. I’ve just checked and I have files in that folder that date back almost a year.

The Xojo one gets cleaned up after a startup or reboot. The files end up in the Trash in a folder called “Recovered Items”. I don’t know how the system determines cleanup for the other files without researching into it. (on Mac)

You could perhaps use a RAMdisk? I haven’t used one of these this century, but?

For Windows, writing to file may be only way.
Don’t worry, if you write file, open it and delete it, it may not even get written out to disk physically.

Thank you. What a useful forum!

Sadly Apple’s QuickTime actually had the facility to create and display a movie from a memoryblock, but like most things from Apple nowadays the replacement (AVFoundation) doesn’t appear to have that function, all I can find is creation via URLs.

Although I would never 100% trust Apple’s documentation (often incomplete), I don’t have the headers here, but maybe later I can take a look.

Well, in our plugin we have a method AVAssetMBS.assetWithData to open from memoryblock, but Apple prefers to go by file.

You could probably accomplish this with a rather different design:

On second thought, this may not solve the problem, as I’m still no sure how you could get data from a Xojo MemoryBlock into the HTMLViewer without also writing it to a file on disk. Hmm. Maybe your Xojo app sets up a TCP server socket on localhost: and the HTML reads from that?