Nextasy2k Posted December 20, 2017 Posted December 20, 2017 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!
Kurapica Posted December 20, 2017 Posted December 20, 2017 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"
Nextasy2k Posted December 20, 2017 Author Posted December 20, 2017 I know this man. But dont know how i should write the code does it works. Sorry
Croll Posted April 11, 2018 Posted April 11, 2018 (edited) 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 April 11, 2018 by Croll code formatting
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now