procedure TForm1.FormCreate(Sender: TObject);
Procedure LoadSound(Value:
String;
index: integer);
Begin
If fileexists(Value)
Then
Sounds[
Index] := BASS_StreamCreateFile(False, PChar(value), 0, 0, BASS_SAMPLE_FX)
Else
showmessage('
Soundmanager : Could not find :' + Value);
// messagebox(handle, Pchar('Could not find :' + Value), 'Error', MB_OK);
End;
Var
Soundpath:
String;
Begin
Soundpath := IncludeTrailingPathDelimiter(ExtractFilePath(paramstr(0)));
setlength(sounds, 1);
// Check if the Library Version is, correkt.
If (BASS_GetVersion()
Shr 16) <> Bassversion
Then
Begin
Showmessage('
Unable to init the Bass Library ver. :' + BASSVERSIONTEXT);
halt;
End;
// Bass.dll initialisieren
// Finitialized := BASS_Init(-1, 44100, 0, h_Wnd, Nil);
If Not Bass_init(-1, 44100, 0, 0,
Nil)
Then
Begin
Showmessage('
Unable to init the device.');
halt;
End;
LoadSound(Soundpath + '
Menu_click.wav', 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Erg:DWord;
Begin
//Erst prüfen ob der Channel noch spielt. ggf. Stop
if (BASS_ChannelisActive(sounds[0]) = BASS_ACTIVE_PLAYING)
then
Bass_ChannelStop(Sounds[0]);
//Da der Channel bereits gespielt wurde oder gestopt wurde, ab zurück zum anfang.
Bass_ChannelSetPosition(Sounds[0],0,BASS_POS_BYTE);
// BASS_ChannelStop(Sounds[0]);
BASS_ChannelPlay(Sounds[0], true);
End;
procedure TForm1.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
//Immer erst prüfen ob der channel läuft. sonst schepperts
if (BASS_ChannelisActive(sounds[0]) = BASS_ACTIVE_PLAYING)
then
Bass_ChannelStop(Sounds[0]);
BASS_StreamFree(sounds[0]);
// Bass.dll freigeben
BASS_Stop;
BASS_Free;
end;