Автор: Unc1e
Дата сообщения: 30.08.2007 13:13
Chanka [more=Здесь][Setup]
AppName=Example.Play.MP3.Music.On.Start.Up.With.Texture
AppVerName=Example.Play.MP3.Music.On.Start.Up.With.Texture
AppPublisher=genri.sampron.iTASmania_Inc.uncle
DefaultDirName=C:\Example.Play.MP3.Music.On.Start.Up.With.Texture
OutputBaseFilename=play.mp3.music.on.start.up.with.texture.by.genri.sampron.iTASmania_Inc.uncle
[Files]
Source: "BASS.dll"; DestDir: "{tmp}"; Flags: dontcopy noencryption
Source: "sound.mp3"; DestDir: "{tmp}"; Flags: dontcopy noencryption nocompression
Source: "MusicButton.bmp"; DestDir: "{tmp}"; Flags: dontcopy
[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;
PlayButton, PauseButton, StopButton: TPanel;
PlayImage, PauseImage, StopImage: TBitmapImage;
PlayLabel, PauseLabel, StopLabel: TLabel;
MouseLabel: Tlabel;
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';
procedure PlayMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
PlayImage.Left := -96
WizardForm.ActiveControl := WizardForm.NextButton
end;
procedure PlayMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
PlayImage.Left := 0
end;
procedure PlayMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if PlayImage.Left <> -96 then PlayImage.Left := -192
StopImage.Left := -64
end;
procedure PauseMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
PauseImage.Left := -128
WizardForm.ActiveControl := WizardForm.NextButton
end;
procedure PauseMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
PauseImage.Left := -32
end;
procedure PauseMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if PauseImage.Left <> -128 then PauseImage.Left := -224
StopImage.Left := -64
end;
procedure StopMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
StopImage.Left := -160
WizardForm.ActiveControl := WizardForm.NextButton
end;
procedure StopMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
StopImage.Left := -64
end;
procedure StopMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if StopImage.Left <> -160 then StopImage.Left := -256
PlayImage.Left := 0
PauseImage.Left := -32
end;
procedure MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
PlayImage.Left := 0
PauseImage.Left := -32
StopImage.Left := -64
end;
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('sound.mp3');
mp3Name := ExpandConstant('{tmp}\sound.mp3');
BASS_Init(-1, 44100, 0, 0, 0);
mp3Handle := BASS_StreamCreateFile(FALSE, PChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
Result := True;
end;
procedure PlayButtonOnClick(Sender: TObject);
begin
case BASS_ChannelIsActive(mp3Handle) of
BASS_ACTIVE_PAUSED:
begin
BASS_ChannelPlay(mp3Handle, False);
PlayButton.Hide
PauseButton.Show
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);
PlayButton.Hide
PauseButton.Show
end;
end;
end;
procedure PauseButtonOnClick(Sender: TObject);
begin
BASS_ChannelPause(mp3Handle);
PauseButton.Hide
PlayButton.Show
end;
procedure StopButtonOnClick(Sender: TObject);
begin
BASS_Stop();
BASS_Free();
PauseButton.Hide
PlayButton.Show
end;
procedure InitializeWizard();
begin
ExtractTemporaryFile('MusicButton.bmp')
MouseLabel := TLabel.Create(WizardForm)
MouseLabel.Width := WizardForm.Width
MouseLabel.Height := WizardForm.Height
MouseLabel.Autosize := False
MouseLabel.Transparent := True
MouseLabel.OnMouseMove := @MouseMove
MouseLabel.Parent := WizardForm
PlayButton := TPanel.Create(WizardForm)
PlayButton.Left := 50
PlayButton.Top := 320
PlayButton.Width := 32
PlayButton.Height := 33
PlayButton.Cursor := crHand
PlayButton.ShowHint := True
PlayButton.Hint := 'Воспроизведение музыки'
PlayButton.OnClick := @PlayButtonOnClick
PlayButton.Parent := WizardForm
PlayImage := TBitmapImage.Create(WizardForm)
PlayImage.Left := 0
PlayImage.Top := 0
PlayImage.Width := 288
PlayImage.Height := 33
PlayImage.Enabled := False
PlayImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\MusicButton.bmp'))
PlayImage.Parent := PlayButton
//
PlayImage.ReplaceColor:=$E2E2E2
PlayImage.ReplaceWithColor:=clBtnFace
PlayLabel := TLabel.Create(WizardForm)
PlayLabel.Width := PlayButton.Width
PlayLabel.Height := PlayButton.Height
PlayLabel.Autosize := False
PlayLabel.Transparent := True
PlayLabel.OnClick := @PlayButtonOnClick
PlayLabel.OnMouseDown := @PlayMouseDown
PlayLabel.OnMouseUp := @PlayMouseUp
PlayLabel.OnMouseMove := @PlayMouseMove
PlayLabel.Parent := PlayButton
PauseButton := TPanel.Create(WizardForm)
PauseButton.Left := 50
PauseButton.Top := 320
PauseButton.Width := 32
PauseButton.Height := 33
PauseButton.Cursor := crHand
PauseButton.ShowHint := True
PauseButton.Hint := 'Приостановить музыку'
PauseButton.OnClick := @PauseButtonOnClick
PauseButton.Parent := WizardForm
PauseImage := TBitmapImage.Create(WizardForm)
PauseImage.Left := -32
PauseImage.Top := 0
PauseImage.Width := 288
PauseImage.Height := 33
PauseImage.Enabled := False
PauseImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\MusicButton.bmp'))
PauseImage.Parent := PauseButton
//
PauseImage.ReplaceColor:=$E2E2E2
PauseImage.ReplaceWithColor:=clBtnFace
PauseLabel := TLabel.Create(WizardForm)
PauseLabel.Width := PauseButton.Width
PauseLabel.Height := PauseButton.Height
PauseLabel.Autosize := False
PauseLabel.Transparent := True
PauseLabel.OnClick := @PauseButtonOnClick
PauseLabel.OnMouseDown := @PauseMouseDown
PauseLabel.OnMouseUp := @PauseMouseUp
PauseLabel.OnMouseMove := @PauseMouseMove
PauseLabel.Parent := PauseButton
StopButton := TPanel.Create(WizardForm)
StopButton.Left := 82
StopButton.Top := 320
StopButton.Width := 32
StopButton.Height := 33
StopButton.Cursor := crHand
StopButton.ShowHint := True
StopButton.Hint := 'Остановить музыку'
StopButton.OnClick := @StopButtonOnClick
StopButton.Parent := WizardForm
StopImage := TBitmapImage.Create(WizardForm)
StopImage.Left := -64
StopImage.Top := 0
StopImage.Width := 288
StopImage.Height := 33
StopImage.Enabled := False
StopImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\MusicButton.bmp'))
StopImage.Parent := StopButton
//
StopImage.ReplaceColor:=$E2E2E2
StopImage.ReplaceWithColor:=clBtnFace
StopLabel := TLabel.Create(WizardForm)
StopLabel.Width := StopButton.Width
StopLabel.Height := StopButton.Height
StopLabel.Autosize := False
StopLabel.Transparent := True
StopLabel.OnClick := @StopButtonOnClick
StopLabel.OnMouseDown := @StopMouseDown
StopLabel.OnMouseUp := @StopMouseUp
StopLabel.OnMouseMove := @StopMouseMove
StopLabel.Parent := StopButton
end;
procedure DeinitializeSetup();
begin
BASS_Stop();
BASS_Free();
end;[/more] Как проверишь - отпишись.