Groups > Borland > Borland Delphi multimedia > Re: TMediaPlayer Center Display




TMediaPlayer Center Display

TMediaPlayer Center Display
Tue, 24 Jul 2007 06:43:43 +010
Hello there,

I am using the TMediaPlayer to play some video files and I've set the
display to a TPanel, however it keeps setting it to the top left hand
corner. I know about DisplayRect property but not sure how to use it.

How would I center the output so its in the middle of the TPanel, no matter
what video is playing? From Torry's tips I can get the width and height of
the currently playing video, so I guess I must base it off that but not sure
how.

Regards
Anthoni

Post Reply
Re: TMediaPlayer Center Display
Tue, 24 Jul 2007 09:19:56 -050
> I am using the TMediaPlayer to play some video files and I've set the
> display to a TPanel, however it keeps setting it to the top left hand
> corner. I know about DisplayRect property but not sure how to use it.
> 
> How would I center the output so its in the middle of the TPanel, no
matter
> what video is playing?

i found some older code of mine (edited for clarity):

procedure TSomeForm.PlayVideo(const AFileName: string);
var
  Size: TPoint;
  NewRect: TRect;
begin
  MediaPlayer.FileName := AFileName;
  MediaPlayer.Open;
  Size.x := DisplayRect.Right - DisplayRect.Left;
  Size.y := DisplayRect.Bottom - DisplayRect.Top;
  NewRect.left := (ClientRect.right + ClientRect.left - Size.x) div 2;
  NewRect.top := (ClientRect.bottom + ClientRect.top - Size.y) div 2;
  NewRect.Right := Size.x;
  NewRect.Bottom := Size.y;
  MediaPlayer.DisplayRect := NewRect;
  MediaPlayer.Play;
end;

for some reason i had to set the right bottom coordinate to the size of
the video.

--
Post Reply
Re: TMediaPlayer Center Display
Wed, 25 Jul 2007 06:13:22 +010
"matthias muntwiler" <muntwiler@ll.net> wrote in message
news:46a60a62@newsgroups.borland.com...
> i found some older code of mine (edited for clarity):

[Snipped]

Thank you, that is perfect. Just what I was looking for.

Regards
Anthoni

Post Reply
Re: TMediaPlayer Center Display
Wed, 25 Jul 2007 10:55:21 +100
Don't use TMediaPlayer .. use DSPack instead - 
http://progdigy.com/modules.php?name=DSPack

it's much more flexible, powerful and open source freeware.

the \Demos\D6-D7\VMR\VMRPlayWin example will have you up and running 
quickly.

there's an active forum for any problems/questions: 
http://progdigy.com/modules.php?name=Forums&file=viewforum&f=1

if your running on Vista and want support for EVR take a look at this 
thread:
http://progdigy.com/modules.php?name=Forums&file=viewtopic&t=3733

- harrie

Anthoni Gardner wrote:
> Hello there,
> 
> I am using the TMediaPlayer to play some video files and I've set the
> display to a TPanel, however it keeps setting it to the top left hand
> corner. I know about DisplayRect property but not sure how to use it.
> 
> How would I center the output so its in the middle of the TPanel, no
matter
> what video is playing? From Torry's tips I can get the width and height of
> the currently playing video, so I guess I must base it off that but not
sure
> how.
> 
> Regards
> Anthoni
> 
Post Reply
about | contact