介绍一下mpegplay这个控件的用法(50分)

  • 主题发起人 主题发起人 fff-1
  • 开始时间 开始时间
F

fff-1

Unregistered / Unconfirmed
GUEST, unregistred user!
我下载了mpegplay这个控件
可不会用
谁能介绍一下用法。(详细点)
谢谢!
 
是呀是呀,我也想知道,我试了很久都没有成功!
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MPEGPlay, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
MPlayer: TMPEGPlayer;
OpenDialog1: TOpenDialog;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CallBackCreateStream (var cant_seek:boolean; var res:pointer);
procedure CallBackCloseStream (handle :pointer);
procedure CallBackRestartStream (handle :pointer; var res:boolean);
procedure CallBackReadStream (handle:pointer;
var read_buffer;
nNumberOfBytesToRead:longint;
var nNumberOfBytesRead:longInt; var res:boolean);
procedure CallBackSeekStream (handle:pointer;
NumBytes,MoveMethod:LongInt; var res:LongInt);
procedure CallBackGetStreamSize (handle:pointer; var res:longint);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
if not OpenDialog1.Execute then exit;
MPlayer.StreamName:=OpenDialog1.FileName;
MPlayer.Open;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
MPlayer.init;
MPlayer.OnOpenStream:=CallBackCreateStream;
MPlayer.OnCloseStream:=CallBackCloseStream;
MPlayer.OnRestartStream:=CallBackRestartStream;
MPlayer.OnGetStreamSize:=CallBackGetStreamSize;
MPlayer.OnSeekStream:=CallBackSeekStream;
MPlayer.OnReadStream:=CallBackReadStream;
end;


procedure TForm1.CallBackCreateStream;
var t:TFileStream;
begin
t:=TFileStream.Create(MPlayer.StreamName, fmOpenRead or fmShareExclusive);
res:=pointer(t);
Cant_seek:=false;
end;

procedure TForm1.CallBackCloseStream;
begin
TFileStream(handle).free;
end;

procedure TForm1.CallBackRestartStream;
begin
res:=((TFileStream(handle).Seek(0,soFromBeginning))=0);
end;

procedure TForm1.CallBackReadStream;
begin
nNumberOfBytesRead:=TFileStream(handle).Read(read_buffer, nNumberOfBytesToRead);
res:=true;
end;

procedure TForm1.CallBackSeekStream;
begin
res:=(TFileStream(handle).Seek(NumBytes,MoveMethod));
end;

procedure TForm1.CallBackGetStreamSize;
begin
res:=TFileStream(handle).Size;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
MPlayer.play;
end;

end.
 
接受答案了.
 
后退
顶部