unit Component1;
interface
uses
SysUtils, Classes, mmsystem, mplayer, Windows;
const
MCI_SETAUDIO = $0873;
MCI_DGV_SETAUDIO_VOLUME = $4002;
MCI_DGV_SETAUDIO_ITEM = $00800000;
MCI_DGV_SETAUDIO_VALUE = $01000000;
MCI_DGV_STATUS_VOLUME = $4019;
type
MCI_DGV_SETAUDIO_PARMS = record
dwCallback: integer;
dwItem: integer;
dwValue: integer;
dwOver: integer;
lpstrAlgorithm: PChar;
lpstrQuality: PChar;
end;
type
MCI_STATUS_PARMS = record
dwCallback: integer;
dwReturn: integer;
dwItem: integer;
dwTrack: integer;
end;
type
TMediaplayerVolume = class(TComponent)
private
FVolume: integer;
FMediaplayer: TMediaplayer;
//function MPGetVolume(MP: TMediaPlayer): Integer;
{ Private-Deklarationen }
protected
{ Protected-Deklarationen }
public
function GetVolume : integer;
{ Public-Deklarationen }
published
property Volume : integer read FVolume write FVolume;
property Mediaplayer: TMediaplayer read FMediaplayer write FMediaplayer;
{ Published-Deklarationen }
end;
procedure Register;
procedure MPSetVolume(MP: TMediaPlayer; Volume: Integer) ;
// procedure GetVolume;
implementation
procedure Register;
begin
RegisterComponents('LPI', [TMediaplayerVolume]);
end;
function GetVolume : integer;
begin
MPSetVolume(FMediaPlayer, FVolume) ;
end;
procedure MPSetVolume(MP: TMediaPlayer; Volume: Integer) ;
var
p: MCI_DGV_SETAUDIO_PARMS;
begin
p.dwCallback := 0;
p.dwItem := MCI_DGV_SETAUDIO_VOLUME;
p.dwValue := Volume;
p.dwOver := 0;
p.lpstrAlgorithm := nil;
p.lpstrQuality := nil;
mciSendCommand(MP.DeviceID, MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p)) ;
end;
function MPGetVolume(MP: TMediaPlayer): Integer;
var
p: MCI_STATUS_PARMS;
begin
p.dwCallback := 0;
p.dwItem := MCI_DGV_STATUS_VOLUME;
mciSendCommand(MP.DeviceID, MCI_STATUS, MCI_STATUS_ITEM, Cardinal(@p)) ;
Result := p.dwReturn;
end;
end.