0

I am quite new to FireMonkey.

I am shifting an old VCL project to Firemonkey. One of the requirements is I need to embed several video players in one form. The player itself needs an HWND parameter to handle its messages. It is very easy to implement using some TPanels in VCL, but I have no idea how to do that in FireMonkey since TCommonCustomForm is the only "container" class I could find that supports TWindowHandle which I can get an HWND.

I googled and found a solution that embeds a FireMonkey form into a VCL form but I failed to do that if I use two FireMonkey forms (perhaps I did it in a wrong way). Some other topics showing how to "move" controls from form1 to form2 are not what I am looking for since I need multiple HWNDs.

How can I do that in FireMonkey? Are there any other TWindowHandle objects that can meet my requirement?

TIA

Edward

NBuyer
  • 36
  • 2
  • Probably the handle of the form will do. Maybe you have to adjust some coordinates with `ClientToScreen` or the like. – Uli Gerhardt Apr 29 '22 at 17:46
  • @UliGerhardt. Thank you for your reply. I might have to do that this way if I have no other better options. – NBuyer Apr 29 '22 at 18:03

2 Answers2

2

Unlike VCL Media Player which renders its content to a specific window Firemonkex Media Player does not support rendering to specific window. Instead FMX Media player is rendering its content to specific TMediaPlyerControl that you place on the form. And yes you can have multiple such controls placed on the form each being connected to its own Media Player.

On Windows this allows to easily play multiple media files at the same time.

But I'm not sure this will work on all other platforms that are supported by Delphi. The reason for this is that on some other platforms like Android and iOS TMediaPlayer just wraps around OS based media player which can perhaps have some of its own limitations like only one active instance.

SilverWarior
  • 7,372
  • 2
  • 16
  • 22
  • Thank you for your reply. I also tried TMediaPlayer several days ago before I started the shifting. TMediaPlayer is quite easy to embed indeed but there are 3 problems: 1. The client side might need to install video CODECs for DX9. 2. The TMediaPlayerControl/TWindowsMedia does not support stretch and resize repaint. I wrote a class helper for TWindowsMedia to solve these problems, not very nice but does the job. 3. TMediaPlayerControl does not generate mouse clicking events when playing video. – NBuyer May 01 '22 at 16:08
  • And I am actually trying to write a similar class like TMediaPlayerControl+TWindowsMedia to create a control with HWND that can hold our video player. This might solve my problem. Thanks again. – NBuyer May 01 '22 at 16:08
1

Finally, I solved this problem by cloning a new control from TMediaPlayerControl and replacing TMediaPlayer with our video player component.

One issue was the new video window did not generate mouse events since it uses DefWindowProc as message handler proc. Just set the lpfnWndProc to a new proc that will forward mouse messages to its parent HWND(your form Handle) when calling Windows.RegisterClass().

Thanks, @SilverWarior.

NBuyer
  • 36
  • 2