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?
 
intheConnect With a Mentor Commented:
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
 
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
All Courses

From novice to tech pro — start learning today.