Jump to content
Tuts 4 You

Help using uFMOD in Delphi!


Nextasy2k

Recommended Posts

I using uFMOD to Play .xm chiptunes in my Project. It works already finde! When i start the program it plays the music and when i close the program it stop playing. But i like to have one Button where i can start and stop the music. 

Like....

If music is playing then

Stop music else

Play music

...

I'm a newbie in Delphi. I Hope anybody can Help me! 

Link to comment

I will quote Mr kao here

Quote

There is a search button in top right corner. You'll be amazed what you can find when you search for "xm player delphi"

 

Link to comment
  • 3 months later...

In my project, I created a global boolean variable called playZik.

var
  playZik: Boolean;


 
In my FormCreate you should have something like the following. Here when the song plays I set my variable TRUE (Playing).

procedure TForm1.FormCreate(Sender: TObject);
begin
	XMPlayFromRes('FOND', 'ZIK');
	playZik := True;
end;

I have a button on my form and enter the following for the OnClick event. This simply checks the flag (our global variable) and if it's TRUE it stops playing the song. If FALSE then it plays, it then just toggles the flag. If True make it False and vice-versa.

procedure TForm1.btnMZKClick(Sender: TObject);
begin
	if playZik then XMStop else XMPlay;
	playZik := not playZik; // toggle flag variable.
end;


Hope this helps. Better late than never lol.

Edited by Croll
code formatting
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...