3

I am using Firemonkey to develop a Win64 video application.

I use TMediaPlayer and TMediaPlayerControl to play video files in full-screen mode.

I hope that when playing a video, the playback time, progress information, and several playback control buttons are superimposed on the playback screen.

But I found that these components added in TMediaPlayerControl cannot be displayed normally. I checked the source code related to TMediaPlayer, and found that the window of the video playback will always be displayed at the top layer, thus completely covering the components above TMediaPlayerControl.

Is there any way to solve this problem?

enter image description here

Leo
  • 1,947
  • 2
  • 20
  • 37

1 Answers1

3

You can do it by adding a transparent overlay form on top (in z order) of the form where your TMediaPlayerControl is. You make the form transparent by setting Transparency = True. To make it stay on top of your main form set FormStyle = StayOnTop. You also want to set its BorderStyle = None.

Place all the buttons, panels etc. that you want to "float" above the video on this transparent form. As the form is transparent, the controls will appear to float in front of the video.

To control your TMediaPlayer with controls on the transparent form, you need to add uses MainForm under implementation in the secondary form.

You will probably also like to synchronize the forms with respect to size changes in case used on different size displays. Use OnFormResize on the main form. Check that the overlay form exists (e.g. if overlayForm <> nil then ...) before you attempt to access it, as it is created after the main form. Set width and height of the overlay form according to the main form. Resposition the controls as needed.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • Thanks for your help, I'm following your prompt. I open the video form from the main form, and then manually create a transparent and StayOnTop form (I found that this transparent form must be manually created each time, otherwise it will still be covered by the video window when it is displayed again.) This solution basically meets my needs. – Leo May 12 '20 at 03:36
  • Okay, another new question: I hope that when the video window is opened, all floating components are not displayed. Only when the user clicks on the video area, the floating component is displayed, and when the user clicks on the video area again, the floating component is hidden. But I failed to achieve this click event: the TMediaplayerControl component does not have OnClick event, and OnTap event cannot be triggered under Windows. On the transparent form, the transparent area cannot be clicked. – Leo May 12 '20 at 04:12
  • As you have noted yourself, it is not possible to have any controls on top the `TMediaPlayerControl` (on the same form). You have also noted already that it is not possible to react on a click on the `TMediaPlayerControl`, and neither on the overlayed transparent form. The only solution I now can think of is to have one button on the transparent form visible all time, which toggles on and off the visibility of the other controls on the form. Well, you could of course also rely on a keybord solution, which you maybe should do in any case, for better usability. – Tom Brunberg May 12 '20 at 08:08
  • 1
    Finally, I also need to bring up the following: I think you have been around long enough to know how SO works, one question per post. You described your problem as not being able to place components on top of the `TMediaPlayerControl` which forces itself on top of all other controls on the same form. Then you asked *Is there any way to solve this problem?* I answered the question and described what you can do. If you have followup questions, you are welcome to ask them as new question posts. – Tom Brunberg May 12 '20 at 08:11