This example effect chart:
Code files:
Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Opendialog1:topendialog;
Timer1:ttimer;
Button1:tbutton;
Button2:tbutton;
Button3:tbutton;
Button4:tbutton;
Procedure Formcreate (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
Procedure Button3click (Sender:tobject);
Procedure Button4click (Sender:tobject);
Procedure Timer1timer (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Bass;
Var
Hs:hstream; {Stream Handle}
Procedure Tform1.formcreate (Sender:tobject);
Begin
Timer1.interval: = 200;
If HiWord (bass_getversion) <> Bassversion Then
MessageBox (0, "Bass.dll" file version is not suitable!) ', nil, mb_iconerror);
If not Bass_init ( -1, 44100, 0, 0, nil) then
ShowMessage (' initialization error ');
End
Open
Procedure Tform1.button1click (Sender:tobject);
Var
mp3path:ansistring;
Begin
Bass_streamfree (HS);
Opendialog1.filter: = ' Mp3 file (*.mp3) |*.mp3| Wav file (*.wav) |*wav ';
If Opendialog1.execute Then
Mp3path: = ansistring (Opendialog1.filename);
HS: = Bass_streamcreatefile (False, Pansichar (Mp3path), 0, 0, 0);
{Want to set up the playback stream as follows, just loop the play}
HS: = Bass_streamcreatefile (False, Pansichar (Mp3path), 0, 0, bass_sample_loop);
If HS < bass_error_ended then Text: = ' Open failed '
End
Play
Procedure Tform1.button2click (Sender:tobject);
Begin
Bass_channelplay (HS, False);
End
Suspended
Procedure Tform1.button3click (Sender:tobject);
Begin
Bass_channelpause (HS);
End
Stop
Procedure Tform1.button4click (Sender:tobject);
Begin
Bass_channelstop (HS);
End
{Monitoring Playback status}
Procedure Tform1.timer1timer (Sender:tobject);
Var
str:string;
Begin
If hs = 0 Then Exit; {Exit} if the playback stream is not established
Case Bass_channelisactive (HS) of
BASS_ACTIVE_STOPPED:STR: = ' stop state ';
Bass_active_playing:str: = ' playing ';
BASS_ACTIVE_STALLED:STR: = ' stall state, waiting for data ';
BASS_ACTIVE_PAUSED:STR: = ' suspend state ';
End
Text: = str;
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Bass_free;
End
End.