Как добавить в этот код еще парочку mp3, чтобы они проигрывались по порядку:
читать дальше »
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;
cb:TCheckBox;
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: PAnsiChar; 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');
BASS_Init(-1, 44100, 0, 0, 0);
mp3Handle := BASS_StreamCreateFile(FALSE, PAnsiChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
Result := True;
end;
procedure cbmusic(Sender: TObject);
begin
if cb.checked = true then
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, PAnsiChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
end;
end;
end;
if cb.checked = false then
BASS_ChannelPause(mp3Handle);
end;
procedure InitializeWizard();
begin
cb:=TCheckBox.Create(WizardForm);
cb.Parent:=WizardForm;
cb.Width:=ScaleX(220);
cb.Left:=ScaleY(10);
cb.Top:=ScaleY(330);
cb.CAPTION:='Проигрывание музыки';
cb.ONCLICK:=@cbmusic;
cb.checked:=true
end;
procedure DeinitializeSetup();
begin
BASS_Stop();
BASS_Free();
end;