Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pl_mpeg + physfs = possible? #19

Open
jarroddavis68 opened this issue Oct 19, 2021 · 3 comments
Open

pl_mpeg + physfs = possible? #19

jarroddavis68 opened this issue Oct 19, 2021 · 3 comments

Comments

@jarroddavis68
Copy link

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

@alichay
Copy link

alichay commented Nov 27, 2021

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

@jarroddavis68
Copy link
Author

@alichay Oh, sorry, just noticed your reply. Ok, I will check this out. Many thanks! 👍🏿

@jarroddavis68
Copy link
Author

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants