D
daver
Unregistered / Unconfirmed
GUEST, unregistred user!
我的QQ82713917
unit FMPPlayer;
interface
uses
SysUtils, Classes,Windows, FMPAPI;
type
TVolume = 0..100;
TShowMode = (TV,VGA);
TVideoMode = (PAL,PAL60,NTSC);
TFMPPlayer = class(TComponent)
private
{ Private declarations }
FVolume :TVolume;
ghStream : Byte;
sFileName : String;
FShowMode : TShowMode;
FVideoMode : TVideoMode;
procedure SetShowMode(Mode:TShowMode);
procedure SetVideoMode(Mode:TVideoMode);
procedure SetVolume(Volume:TVolume);
function GetVolume:TVolume;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
function OpenDriver:Boolean;
function Open:Boolean;
procedure Close;
procedure Stop;
procedure Pause;
procedure CloseDriver;
published
{ Published declarations }
property FileName: String read sFileName write sFileName;
property ShowMode: TShowMode read FShowMode write SetShowMode default TV;
property VideoMode: TVideoMode read FVideoMode write SetVideoMode default PAL;
property Volume: TVolume read GetVolume write SetVolume default 50;
end;
procedure Register;
implementation
{************************* Register ******************************}
procedure Register;
begin
RegisterComponents('Samples', [TFMPPlayer]);
end;
{************************* Create ******************************}
constructor TFMPPlayer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ghStream := 0 ;
sFileName := '' ;
FShowMode := TV ;
FVideoMode := PAL ;
FVolume:=50;
end;
{***************** Destroy *************************************}
destructor TFMPPlayer.Destroy;
begin
inherited Destroy;
end;
{***************** OpenDriver *************************************}
function TFMPPlayer.OpenDriver:Boolean;
var
sOpen:Integer;
begin
sOpen:=FMPOpenDriver;
if sOpen <= 0 then
Result:=False
else
Result:=True;
end;
{***************** CloseDriver *************************************}
procedure TFMPPlayer.CloseDriver;
begin
FMPCloseDriver;
end;
{***************** CloseDriver *************************************}
function TFMPPlayer.Open:Boolean;
begin
ghStream := FMPOpen(FMPF_FILE,dword(PChar(sFileName)));
if ghStream <= 0 then
Result:=False
else
Result:=True;
end;
{***************** Close *************************************}
procedure TFMPPlayer.Close;
begin
if ghStream <= 0 then
Exit;
FMPClose(ghStream);
end;
{***************** Stop *************************************}
procedure TFMPPlayer.Stop ;
begin
if ghStream <= 0 then
Exit;
FMPStop(ghStream);
end;
{***************** Pause *************************************}
procedure TFMPPlayer.Pause ;
begin
if ghStream <= 0 then
Exit;
FMPPause(ghStream);
end;
procedure TFMPPlayer.SetShowMode(Mode:TShowMode);
begin
FShowMode:=Mode;
if ghStream <= 0 then
Exit;
begin
Case Mode of
TV : FMPSet(ghStream,FMPI_VID_TV,FMPF_TV);
VGA : FMPSet(ghStream,FMPI_VID_TV,FMPF_VGA);
end;
end;
end;
procedure TFMPPlayer.SetVideoMode(Mode:TVideoMode);
begin
FVideoMode:=Mode;
if ghStream <= 0 then
Exit;
begin
Case Mode of
PAL : FMPSet(ghStream,FMPI_VID_TV,FMPF_PAL or FMPF_TV);
PAL60 : FMPSet(ghStream,FMPI_VID_TV,FMPF_PAL60 or FMPF_TV);
NTSC : FMPSet(ghStream,FMPI_VID_TV,FMPF_NTSC or FMPF_TV);
end;
end;
end;
procedure TFMPPlayer.SetVolume(Volume:TVolume);
var
V:dword;
begin
if Volume <
0 then
Volume := 0;
if Volume >
100 then
Volume :=100;
FVolume:=Volume;
if ghStream <= 0 then
Exit;
V := makelong(Volume,Volume);
FMPSet(ghStream,FMPI_AUD_VOLUME,V);
end;
function TFMPPlayer.GetVolume:TVolume;
begin
Result:=FVolume;
if ghStream <= 0 then
Exit;
Result:=FMPGet(ghStream,FMPI_AUD_VOLUME);
end;
end.
unit FMPPlayer;
interface
uses
SysUtils, Classes,Windows, FMPAPI;
type
TVolume = 0..100;
TShowMode = (TV,VGA);
TVideoMode = (PAL,PAL60,NTSC);
TFMPPlayer = class(TComponent)
private
{ Private declarations }
FVolume :TVolume;
ghStream : Byte;
sFileName : String;
FShowMode : TShowMode;
FVideoMode : TVideoMode;
procedure SetShowMode(Mode:TShowMode);
procedure SetVideoMode(Mode:TVideoMode);
procedure SetVolume(Volume:TVolume);
function GetVolume:TVolume;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
function OpenDriver:Boolean;
function Open:Boolean;
procedure Close;
procedure Stop;
procedure Pause;
procedure CloseDriver;
published
{ Published declarations }
property FileName: String read sFileName write sFileName;
property ShowMode: TShowMode read FShowMode write SetShowMode default TV;
property VideoMode: TVideoMode read FVideoMode write SetVideoMode default PAL;
property Volume: TVolume read GetVolume write SetVolume default 50;
end;
procedure Register;
implementation
{************************* Register ******************************}
procedure Register;
begin
RegisterComponents('Samples', [TFMPPlayer]);
end;
{************************* Create ******************************}
constructor TFMPPlayer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ghStream := 0 ;
sFileName := '' ;
FShowMode := TV ;
FVideoMode := PAL ;
FVolume:=50;
end;
{***************** Destroy *************************************}
destructor TFMPPlayer.Destroy;
begin
inherited Destroy;
end;
{***************** OpenDriver *************************************}
function TFMPPlayer.OpenDriver:Boolean;
var
sOpen:Integer;
begin
sOpen:=FMPOpenDriver;
if sOpen <= 0 then
Result:=False
else
Result:=True;
end;
{***************** CloseDriver *************************************}
procedure TFMPPlayer.CloseDriver;
begin
FMPCloseDriver;
end;
{***************** CloseDriver *************************************}
function TFMPPlayer.Open:Boolean;
begin
ghStream := FMPOpen(FMPF_FILE,dword(PChar(sFileName)));
if ghStream <= 0 then
Result:=False
else
Result:=True;
end;
{***************** Close *************************************}
procedure TFMPPlayer.Close;
begin
if ghStream <= 0 then
Exit;
FMPClose(ghStream);
end;
{***************** Stop *************************************}
procedure TFMPPlayer.Stop ;
begin
if ghStream <= 0 then
Exit;
FMPStop(ghStream);
end;
{***************** Pause *************************************}
procedure TFMPPlayer.Pause ;
begin
if ghStream <= 0 then
Exit;
FMPPause(ghStream);
end;
procedure TFMPPlayer.SetShowMode(Mode:TShowMode);
begin
FShowMode:=Mode;
if ghStream <= 0 then
Exit;
begin
Case Mode of
TV : FMPSet(ghStream,FMPI_VID_TV,FMPF_TV);
VGA : FMPSet(ghStream,FMPI_VID_TV,FMPF_VGA);
end;
end;
end;
procedure TFMPPlayer.SetVideoMode(Mode:TVideoMode);
begin
FVideoMode:=Mode;
if ghStream <= 0 then
Exit;
begin
Case Mode of
PAL : FMPSet(ghStream,FMPI_VID_TV,FMPF_PAL or FMPF_TV);
PAL60 : FMPSet(ghStream,FMPI_VID_TV,FMPF_PAL60 or FMPF_TV);
NTSC : FMPSet(ghStream,FMPI_VID_TV,FMPF_NTSC or FMPF_TV);
end;
end;
end;
procedure TFMPPlayer.SetVolume(Volume:TVolume);
var
V:dword;
begin
if Volume <
0 then
Volume := 0;
if Volume >
100 then
Volume :=100;
FVolume:=Volume;
if ghStream <= 0 then
Exit;
V := makelong(Volume,Volume);
FMPSet(ghStream,FMPI_AUD_VOLUME,V);
end;
function TFMPPlayer.GetVolume:TVolume;
begin
Result:=FVolume;
if ghStream <= 0 then
Exit;
Result:=FMPGet(ghStream,FMPI_AUD_VOLUME);
end;
end.