pl_mpeg
pl_mpeg copied to clipboard
pl_mpeg + physfs = possible?
Hi, I'm looking around for a video playback solution and considering pl_mpeg. Can it be made to work with physfs?? I'm currently using physfs to load resources from a zip archive, so I need to be able to also play the videos from this archive as well. At present I don't see a way to easily do it. Maybe I've overlooked something, please advise.
Thanks
Jarrod
This is absolutely possible!
It mostly comes down to using plm_create_from_memory
and then handling the file read yourself using the physfs API.
For a little bit of a jumpstart, I went ahead and modified the video player example from this repository to use physfs instead, to demonstrate how to join these libraries better :)
https://gist.github.com/alichay/0e1096a3e147b02a097190870345bea2
@alichay Oh, sorry, just noticed your reply. Ok, I will check this out. Many thanks! 👍🏿
Actually, if you use the buffer interface, then you can read in chucks at a time and not have to load the whole thing into memory.
procedure plm_buffer_load(buffer: Pplm_buffer_t; user: Pointer); cdecl;
const
LBufSize = 1024*2;
var
LBuff: array[1..LBufSize] of Byte;
begin
if PHYSFS_eof(Phys) <> 0 then
begin
if plm_get_loop(Plm) = 1 then
PHYSFS_seek(Phys, 0);
else
plm_buffer_signal_end(buffer);
end
else
begin
PHYSFS_readBytes(Phys, @LBuff[1], LBufSize);
plm_buffer_write(buffer, @LBuff[1], LBufSize);
end;
end;