Web Development

General discussion


Using Gifs or AVIs in Delphi 5

By mattreid ·
I would like to know how I could get an animated Gif or an AVI to display in Delphi.

I've gone through the help files with regard to AVIs but the example shown(using both the 'animate' and 'mediaplayer' objects) only works with the file you are told to open, every other one I've tried gives the error "cannot open AVI".

And as far as I know the Gif format is unrecognised in both the 'animate' and 'mediaplayer' objects.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by atjjensen In reply to Using Gifs or AVIs in Del ...

hmm...well, lets start with AVI's. Here is a little snip of code from an application I have out. It works fine for me displaying multimedia files. Of course there are certain files that I cannot get to play in MS-MediaPlayer iself, and they won't play here either.

procedure TfrmQuestionEditor.sbtnOpenResourceClick(Sender: TObject);
with OpenDialog1 do begin
FileName := '';
Filter := 'All (*.mpg, *.mpeg, *.avi, *.mp3, *.wav)|*.mpg;*.mpeg;*.avi;*.mp3;*.wav|' +
'Video (*.mpg, *.mpeg, *.avi)|*.mpg;*.mpeg;*.avi|' +
'Sound (*.mp3, *.wav)|*.mp3;*.wav';
if execute then begin
edresourceName.Text := Filename;
if cbxResourcePreview.Checked then begin
MediaPlayer1.FileName := Filename;
MediaPlayer1.Display := pnlDisplay;
MediaPlayer1.DisplayRect := pnlDisplay.ClientRect;
end; // if checked
end; // if execute;
end; // with

I will go into GIF's in the next message.


Collapse -

by atjjensen In reply to Using Gifs or AVIs in Del ...

OK, now for GIF's. You are correct Delphi 5, has no support for GIF file format in the VCL. This is due to some legal issues regarding Copyright at the time it shipped. However, there are any number of freeware, shareware and commercial components available that will give you this capability. I might recommend the following file:
TGif Image V2.2, which you can find at www.torry.net.

This will subclass your TImage component so that it will work with any type of gif image, transparent and animated.

As for opening a GIF file with MEdiaPlayer or TAnimate, neither of these components where intended for opeing GIF files. MediaPlayer should not need an explenation, while TAnimate is just a very trimmed down version of the MEdiaPlayer.


Related Discussions

Related Forums