Sampron Цитата: У меня нету кода для кнопок управления MP3.
Вот [more=код]
Код: [Setup]
AppName=My Program
AppVerName=My Program 1.5
AppPublisher=My Company, Inc.
DefaultDirName=C:\example
[Files]
Source: BASS.dll; DestDir: " {tmp} "; Flags: dontcopy noencryption
Source: music.mp3; DestDir: "{tmp}"; Flags: dontcopy noencryption nocompression
[Code]
const
BASS_ACTIVE_STOPPED = 0;
BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
BASS_SAMPLE_LOOP = 4;
var
mp3Handle: HWND;
mp3Name: string;
function BASS_Init(device: Integer; freq, flags: DWORD; win: hwnd; CLSID: Integer): Boolean;
external 'BASS_Init@files:BASS.dll stdcall delayload';
function BASS_StreamCreateFile(mem: BOOL; f: PChar; offset: DWORD; length: DWORD; flags: DWORD): DWORD;
external 'BASS_StreamCreateFile@files:BASS.dll stdcall delayload';
function BASS_Start(): Boolean;
external 'BASS_Start@files:BASS.dll stdcall delayload';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): Boolean;
external 'BASS_ChannelPlay@files:BASS.dll stdcall delayload';
function BASS_ChannelIsActive(handle: DWORD): Integer;
external 'BASS_ChannelIsActive@files:BASS.dll stdcall delayload';
function BASS_ChannelPause(handle: DWORD): Boolean;
external 'BASS_ChannelPause@files:BASS.dll stdcall delayload';
function BASS_Stop(): Boolean;
external 'BASS_Stop@files:BASS.dll stdcall delayload';
function BASS_Pause(): Boolean;
external 'BASS_Pause@files:BASS.dll stdcall delayload';
function BASS_Free(): Boolean;
external 'BASS_Free@files:BASS.dll stdcall delayload';
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('music.mp3');
mp3Name := ExpandConstant('{tmp}\music.mp3');
mp3Handle := BASS_StreamCreateFile(FALSE, PChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
Result := True;
end;
procedure PlayButtonOnClick(Sender: TObject);
begin
case BASS_ChannelIsActive(mp3Handle) of
BASS_ACTIVE_PAUSED:
begin
BASS_ChannelPlay(mp3Handle, False);
end;
BASS_ACTIVE_STOPPED:
begin
BASS_Init(-1, 44100, 0, 0, 0);
mp3Handle := BASS_StreamCreateFile(FALSE, PChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
end;
end;
end;
procedure PauseButtonOnClick(Sender: TObject);
begin
BASS_ChannelPause(mp3Handle);
end;
procedure StopButtonOnClick(Sender: TObject);
begin
BASS_Stop();
BASS_Free();
end;
procedure InitializeWizard();
var
Name: string;
PlayButton, PauseButton, StopButton: TButton;
Text: TNewStaticText;
Panel: TPanel;
begin
WizardForm.Position := poScreenCenter;
WizardForm.CancelButton.BringToFront;
begin
Panel := TPanel.Create(WizardForm);
with Panel do
begin
Parent := WizardForm;
Left := ScaleX(1);
Top := ScaleY(315);
Width := ScaleX(165);
Height := ScaleY(46);
TabOrder := 0;
Color := clWhite;
BevelInner := bvLowered;
BevelOuter := bvRaised;
BorderStyle := bsSingle;
end
PlayButton := TButton.Create(WizardForm);
with PlayButton do
begin
Left := 5;
Top := 335;
Width := 50;
Height := 20;
Caption := 'Play';
OnClick := @PlayButtonOnClick;
Parent := WizardForm;
Cursor := crHand;
ShowHint := True;
Hint := 'Âîñïðîèçâåäåíèå ìóçûêè';
end
PauseButton := TButton.Create(WizardForm);
with PauseButton do
begin
Left := 58;
Top := 335;
Width := 50;
Height := 20;
Caption := 'Pause';
OnClick := @PauseButtonOnClick;
Parent := WizardForm;
Cursor := crHand;
ShowHint := True;
Hint := 'Ïðèîñòàíîâèòü ìóçûêó';
end
StopButton := TButton.Create(WizardForm);
with StopButton do
begin
Left := 111;
Top := 335;
Width := 50;
Height := 20;
Caption := 'Stop';
OnClick := @StopButtonOnClick;
Parent := WizardForm;
Cursor := crHand;
ShowHint := True;
Hint := 'Îñòàíîâèòü ìóçûêó';
end
Text := TNewStaticText.Create(WizardForm);
with Text do
begin
Caption := 'Music Box';
Parent := WizardForm;
Font.Style := Text.Font.Style + [fsUnderline];
Font.Color := clNavy;
Top := 319;
Left := 57;
Color := clWhite;
end
end;
end;
procedure DeinitializeSetup();
begin
BASS_Stop();
BASS_Free();
end;