Jump to content
Tuts 4 You
Sign in to follow this  
Nextasy2k

Help using uFMOD in Delphi!

Rate this topic

Recommended Posts

Nextasy2k

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! 

Share this post


Link to post
Share on other sites
Kurapica

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"

 

Share this post


Link to post
Share on other sites
Nextasy2k

I know this man. But dont know how i should write the code does it works. Sorry

Share this post


Link to post
Share on other sites
Croll

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 (see edit history)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×
×
  • Create New...