{ Set time format - note that some devices don抰 support tfHMS }
MediaPlayer1.TimeFormat := tfHMS;
{ Store length of currently loaded media }
TheLength := MediaPlayer1.Length;
with HMSRec(TheLength) do { Typecast TheLength as a HMSRec record }
begin
Label1.Caption := IntToStr(Hours); { Display Hours in Label1 }
Label2.Caption := IntToStr(Minutes); { Display Minutes in Label2 }
Label3.Caption := IntToStr(Seconds); { Display Seconds in Label3 }
end;
end;
unit Vfw;
////////////////////////////////////////////////////////////////////////////////
// //
// Video for Windows //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// Adapted from Thomas Schimming's VFW.PAS //
// (c) 1996 Thomas Schimming, schimmin@iee1.et.tu-dresden.de //
// (c) 1998,99 Anders Melander //
// //
////////////////////////////////////////////////////////////////////////////////
// //
// Ripped all COM/ActiveX stuff and added some AVI stream functions. //
// //
////////////////////////////////////////////////////////////////////////////////
interface
procedure AVIFileInit; stdcall; external 'avifil32.dll' name 'AVIFileInit';
procedure AVIFileExit; stdcall; external 'avifil32.dll' name 'AVIFileExit';
function AVISaveOptions;stdcall;external 'avifil32.dll' name 'AVISaveOptions';
function AVIFileOpen; external 'avifil32.dll' name 'AVIFileOpenA';
function AVIFileCreateStream; external 'avifil32.dll' name 'AVIFileCreateStreamA';
function AVIStreamSetFormat; external 'avifil32.dll' name 'AVIStreamSetFormat';
function AVIStreamReadFormat; external 'avifil32.dll' name 'AVIStreamReadFormat';
function AVIStreamWrite; external 'avifil32.dll' name 'AVIStreamWrite';
function AVIStreamWriteData; external 'avifil32.dll' name 'AVIStreamWriteData';
function AVIStreamRelease; external 'avifil32.dll' name 'AVIStreamRelease';
function AVIFileRelease; external 'avifil32.dll' name 'AVIFileRelease';
function AVIFileGetStream; external 'avifil32.dll' name 'AVIFileGetStream';
function AVIStreamBeginStreaming; external 'avifil32.dll' name 'AVIStreamBeginStreaming';
function AVIStreamEndStreaming; external 'avifil32.dll' name 'AVIStreamEndStreaming';
function AVIStreamGetFrameOpen; external 'avifil32.dll' name 'AVIStreamGetFrameOpen';
function AVIStreamGetFrame; external 'avifil32.dll' name 'AVIStreamGetFrame';
function AVIStreamGetFrameClose; external 'avifil32.dll' name 'AVIStreamGetFrameClose';
function AVIStreamInfo; external 'avifil32.dll' name 'AVIStreamInfo';
function AVIStreamLength; external 'avifil32.dll' name 'AVIStreamLength';
function CreateEditableStream; external 'avifil32.dll' name 'CreateEditableStream';
function EditStreamSetInfo; external 'avifil32.dll' name 'EditStreamSetInfo';
function AVIMakeFileFromStreams; external 'avifil32.dll' name 'AVIMakeFileFromStreams';
function AVISave; external 'avifil32.dll' name 'AVISave';
function AVIMakeCompressedStream;external 'avifil32.dll' name 'AVIMakeCompressedStream';
(*
typedef struct {
unsigned long dwMicroSecPerFrame;
unsigned long dwMaxBytesPerSec;
unsigned long dwReserved1;
unsigned long dwFlags;
unsigned long dwTotalFrames;
unsigned long dwInitialFrames;
unsigned long dwStreams;
unsigned long dwSuggestedBufferSize;
unsigned long dwWidth;
unsigned long dwHeight;
unsigned long dwScale;
unsigned long dwRate;
unsigned long dwStart;
unsigned long dwLength;
} MainAVIHeader;
typedef struct {
unsigned long fccType;
unsigned long fccHandler;
unsigned long dwFlags;
unsigned long dwReserved1;
unsigned long dwInitialFrames;
unsigned long dwScale;
unsigned long dwRate;
unsigned long dwStart;
unsigned long dwLength;
unsigned long dwSuggestedBufferSize;
unsigned long dwQuality;
unsigned long dwSampleSize;
unsigned long dwReserved2;
unsigned long dwReserved3;
} AVIStreamHeader;
procedure TForm1.FileListBox1Click(Sender: TObject);
begin
if FileListbox1.SelCount =0 then exit;
With mediaPlayer1 do begin
Close;
TimeFormat := tfMilliseconds;
FileName :=FileListbox1.FileName ;
Open ;
progressbar1.Max :=Length;
play;
timer1.Enabled :=true;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Mediaplayer1.Mode =mpPlaying then begin
progressbar1.Position :=mediaplayer1.Position ;
end else begin
progressbar1.Position :=0;
timer1.Enabled :=false;
end;
end;