What is the avi width and height

If I load an avi into Tmediaplayer, how can I read the default width and height? (I can stretch it to a specific height, but I want the default).
D3 / win98

                Thanks
           
jexd99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
hi the difficult way:

type
  TAVIFileInfo = packed record
    dwMaxBytesPerSec: LongInt;
    dwFlags: LongInt;
    dwCaps: LongInt;
    dwStreams: LongInt;
    dwSuggestedBufferSize: LongInt;
    dwWidth: LongInt;
    dwHeight: LongInt;
    dwScale: LongInt;
    dwRate: LongInt;
    dwLength: LongInt;
    dwEditCount: LongInt;
    szFileType: array[0..63] of Char;
  end;
 
function AVIFileInit: LongInt; stdcall; external 'avifil32.dll'; function AVIFileOpen(var pFile: Pointer; szFile: PChar; Mode: Word; pclsidHandler: Pointer): LongInt; stdcall; external 'avifil32.dll'; function AVIFileInfo(pFile: Pointer; var pFI: TAVIFileInfo; lSize: LongInt): LongInt; stdcall; external 'avifil32.dll';
function AVIFileRelease(pFile: Pointer): LongInt; stdcall; external 'avifil32.dll';
function AVIFileExit: LongInt; stdcall; external 'avifil32.dll';
 
procedure GetAVIDetails(const FileName: string; var Width, Height: Integer); var
  F: Pointer;
  AFI: TAVIFileInfo;
begin
  AVIFileInit;
  try
    if AVIFileOpen(F, PChar(FileName), OF_READ or OF_SHARE_DENY_NONE, nil) = 0 then
    try
      if AVIFileInfo(F, AFI, SizeOf(AFI)) = 0 then
      begin
        Width := AFI.dwWidth;
        Height := AFI.dwHeight;
      end else
        raise Exception.Create('Unable to get AVI file info');
    finally
      AVIFileRelease(F);
    end else
      raise Exception.Create('Unable to open AVI file');
  finally
    AVIFileExit;
  end;
end;
 
You pass GetAVIDetails the filename of the avi file and two integer variables that will receive the width and the height of the AVI file.  Here is a code fragment (from a TButton.OnClick event) that demonstrates the call:
 
 
procedure Form1.Button1Click(Sender: TObject);
var
  W, H: Integer;
begin
  try
    GetAVIDetails('myavifile.avi', W, H);
    ShowMessage(Format('Width: %d Height: %d', [W, H]));
  except
    on E: Exception do ShowMessage(Format('Error: %s', [E.Message]));   end;
end;


the simple way :

var
  rectWidth,
  rectHeight : integer;
begin  
 
MediaPlayer1.DisplayRect := Rect(0, 0, 0, 0);
        //the zero parameters set the mediaplayer to whatever
        //the size of the AVI file, and puts its top-left corner         //at 0,0.
 
//with the origin at 0,0
//then the Right property of the mediaplayer.DisplayRect  = width //and the Bottom of the mediaplayer.DisplayRect = height
 
rectWidth := MediaPlayer1.DisplayRect.Right;
rectHeight := MediaPlayer1.DisplayRect.Bottom;
 
end;
 
Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwilson032697Commented:
Listening
0
TheNeilCommented:
That's a bit of a long winded way to day the job, try the following instead:

MediaPlayer1.DisplayRect.Right
MediaPlayer1.DisplayTect.Bottom;

The Right value gives you the width, and the Bottom gives you the height. Far simpler than inthe's code.

The Neil
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

intheCommented:
and what are the last 2 lines of my code under the heading "the simple way" ?

0
TheNeilCommented:
Oops - Sorry inthe, I spotted your last two lines AFTER I'd posted my comment.

The Neil
0
jexd99Author Commented:
Thank you.  I think I'll go with the "simple" way. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.