Recent

Author Topic: [SOLVED] Window SDL2 Drop Files  (Read 1357 times)

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
[SOLVED] Window SDL2 Drop Files
« on: January 28, 2023, 11:02:57 am »
Hello forumers, what do I need to do to make sdl window support file drop ?
« Last Edit: February 21, 2023, 05:15:52 pm by Pe3s »

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: Window SDL2 Drop Files
« Reply #1 on: January 31, 2023, 03:26:03 pm »
Add a SDL-EventLoop, like...

Code: [Select]
uses
  sdl2, …

var
  aSdlEvent: TSDL_Event;
...

while True do
begin

  SDL_WaitEvent(@aSdlEvent);

  case aSdlEvent.type_ of

    SDL_DROPFILE:
    begin
      ...
    end;

  end;

end;
« Last Edit: February 01, 2023, 01:35:42 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
Re: Window SDL2 Drop Files
« Reply #2 on: January 31, 2023, 07:13:34 pm »
@metis you can combine code with sdl drop files
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of string);
  2. var
  3.   i: Integer;
  4. begin
  5.   for i:= Low(FileNames) to High(FileNames) do
  6.   OpenVideo(FileNames[i]);
  7. end;  
  8.  

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: Window SDL2 Drop Files
« Reply #3 on: January 31, 2023, 07:35:01 pm »
@Pe3s

Your Code is for how to do it with a LCL-Form, but You asked how to do it with a SDL2-Window.  ;D
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
Re: Window SDL2 Drop Files
« Reply #4 on: February 01, 2023, 07:54:57 pm »
@metis is it possible to write a video file renderer to support LCLForm?

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: Window SDL2 Drop Files
« Reply #5 on: February 02, 2023, 02:49:09 pm »
@Pe3s

If I get You right, you're asking, if it is possible to write a VideoPlayer, that runs inside a LCL-Form.

Yes, it is with a little Help of a VideoPlayback-Library, or (better :D) with my FFmpeg-based Audio/Video-RenderingEngine 'FFPlay4Laz':
The latest Version with SDL2 is here, the latest Version with FFPlay4Laz-Library and Demo-LCL-GUI (but still SDL1) is here.
« Last Edit: February 02, 2023, 03:37:07 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
Re: Window SDL2 Drop Files
« Reply #6 on: February 02, 2023, 06:48:48 pm »
@metis, Thank you  :)

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
Re: [SOLVED] Window SDL2 Drop Files
« Reply #7 on: February 19, 2023, 12:22:53 pm »
@metis, Hello, you need to write some procedure for this method that handles dropping files, because it doesn't work with Dropfiles?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of string);
  2. var
  3.   aSdlEvent: TSDL_Event;
  4. begin
  5.   while True do
  6.   begin
  7.     SDL_WaitEvent(@aSdlEvent);
  8.     case aSdlEvent.type_ of
  9.       SDL_DROPFILE: begin
  10.         OpenVideo(FileNames[0]);
  11.       end;
  12.     end;
  13.   end;
  14. end;
  15.  
« Last Edit: February 19, 2023, 04:23:43 pm by Pe3s »

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: Window SDL2 Drop Files
« Reply #8 on: February 19, 2023, 05:03:56 pm »
See here, and GoTo "For how it's done, take a Look at that MediaPlayer's BasicStructure (Projectname: 'FFPlay4Laz')".
There You will find the complete FPC-Code to open SDL1- resp. SDL2-Windows and write EventLoops for them.
For the Dropfile-Event in particular, see here.

And, don't mix up
DropFile on a LCL-Form (that's, what You're trying all the Time ;D) with
DropFile on a SDL-Window (that's, what You've been asking for in Your OP).
« Last Edit: February 20, 2023, 01:48:35 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
Re: Window SDL2 Drop Files
« Reply #9 on: February 20, 2023, 05:43:28 pm »
Probably that's why I think wrong because the sdl window is displayed on the lcl form.
Regards

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: Window SDL2 Drop Files
« Reply #10 on: February 20, 2023, 08:50:16 pm »
Obviously, You attempt to code a VideoPlayer.
Why don't You simply take e.g. the VLC-Component as explained here:
http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html.
It comes together with a complete Lazarus-Project - see the Attachment.
(I took out the Executable to get under the 500KB-Limit for Attachments.)
« Last Edit: February 20, 2023, 09:21:28 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Pe3s

  • Sr. Member
  • ****
  • Posts: 372
Re: Window SDL2 Drop Files
« Reply #11 on: February 21, 2023, 05:15:36 pm »
@metis, However, I will read more about SDL. Thank you for your patience. Regards

metis

  • Sr. Member
  • ****
  • Posts: 257
Re: [SOLVED] Window SDL2 Drop Files
« Reply #12 on: February 21, 2023, 06:17:53 pm »
You're welcome.  :)

Start with the Tutorials by 'Free Pascal meets SDL':
https://www.freepascal-meets-sdl.net/sdl-tutorials/
« Last Edit: February 22, 2023, 01:52:56 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

 

TinyPortal © 2005-2018