• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Progress Loading/Playing AVI

How can I know and show the progress of loading and playing an AVI files from TMediaPlayer?
0
tribby
Asked:
tribby
  • 4
  • 2
  • 2
1 Solution
 
simonetCommented:
Only by using a TTimer.
0
 
tribbyAuthor Commented:
What tells me the progress..how much to go loading..playing..etc?
0
 
intheCommented:
roughly like:

procedure TForm1.FormCreate(Sender: TObject);
begin
mediaplayer1.display := panel1;
timer1.enabled:=false;
timer1.interval := 100;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
opendialog1.execute;
progressbar1.max := mediaplayer1.Length;
mediaplayer1.FileName:=opendialog1.filename;
mediaplayer1.play;
timer1.enabled:=true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
progressbar1.position := mediaplayer1.position;
end;


can also use mediaplayer1.tracklenght etc..

Regards Barry
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
tribbyAuthor Commented:
Anyone know how to show the progress for the actual loading?
0
 
intheCommented:
from fmxutils.pas

function GetFileSize(const FileName: string): LongInt;
var
  SearchRec: TSearchRec;
begin
  if FindFirst(ExpandFileName(FileName), faAnyFile, SearchRec) = 0 then
    Result := SearchRec.Size
  else Result := -1;
end;


div the filesize by 100 for instance and use that with progress bar ..
otherwise you probably looking at a blockread type thing which is more complicated..
0
 
tribbyAuthor Commented:
Ok..but what returns how much of the AVI is loaded so far...that will just give me the total to load.
0
 
simonetCommented:
You can't know how much of the AVI file has been loaded because that's not handled by your application, but by Windows instead (the multimedia subsystem).

Like Barry said, you can write the loading procedure yourself (WAY TOO MUCH WORK). Unless you're willing to do that, forget about the ProgressBar.

Now, if you're willing to create the loading procedure, then you must forget about TMediaPlayer. You'll have to look for a solution that works with streaming or playing the AVI file from a memory block (windows can do that but only for Wave files).

Another option, but a dirty, ugly one, is to profile the HD's transfer rate, retrieve the file size and calculate how long it will take to load (considering the file is in contiguous blocks in the HD). Then you upgrade the progress bar according to how long it has taken, rather than how much has been loaded. Again, this is also a very hard-to-implement solution.

Alex
0
 
tribbyAuthor Commented:
That at leaast gave me 1/2 of what I wanted..thank you.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now