Computer Science Canada

Music playing thru GUI

Author:  chrispaks [ Sun May 22, 2005 2:03 pm ]
Post subject:  Music playing thru GUI

I want it to play Metallica - Fuel from a GUI, but I need help in making it work Wink

heres what I Got

Quote:

proc PlayFuel
Music.PlayFile ("Fuel.mp3")
end PlayFuel

%Music Buttons
Fuel := GUI.CreateButton (5, 500 - 125, 120, "Fuel", PlayFuel)


Do I have to put a fork in or something?
OR do you need more code because im missing something?

EDIT: It works, but how do I get it to stop playing with a button thats designed to make it stop?

Author:  Delos [ Sun May 22, 2005 2:07 pm ]
Post subject: 

GUI is strange. To make it run, you need to following at the end of your code:

Turing:

loop
  exit when GUI.ProcessEvent
end loop

Author:  MysticVegeta [ Sun May 22, 2005 2:11 pm ]
Post subject: 

code:
import GUI

procedure PlayFuel
    Music.PlayFileLoop ("Fuel.mid")
end PlayFuel

%Music Buttons
var Fuel := GUI.CreateButton (5, 500 - 125, 120, "Fuel", PlayFuel)
var qut := GUI.CreateButton (5, 300, 120, "STOP!", GUI.Quit)

loop
    exit when GUI.ProcessEvent
end loop
Music.PlayFileStop

Author:  chrispaks [ Sun May 22, 2005 8:17 pm ]
Post subject: 

MysticVegeta wrote:
code:
import GUI

procedure PlayFuel
    Music.PlayFileLoop ("Fuel.mid")
end PlayFuel

%Music Buttons
var Fuel := GUI.CreateButton (5, 500 - 125, 120, "Fuel", PlayFuel)
var qut := GUI.CreateButton (5, 300, 120, "STOP!", GUI.Quit)

loop
    exit when GUI.ProcessEvent
end loop
Music.PlayFileStop


is there a way to make it stop, since im gonna have options of the program and stuff... its a huge thing where i need a button to stop it, not exit the program Razz

Author:  Delos [ Sun May 22, 2005 9:41 pm ]
Post subject: 

Yes. Since you've started the play with a Music. command, you can use another Music. command to stop it. I believe it is Music.PlayFileStop(). Look it up.

Author:  MysticVegeta [ Mon May 23, 2005 9:32 am ]
Post subject: 

Making a different procedure can do it Laughing
code:
import GUI

procedure PlayFuel
    Music.PlayFileLoop ("music/Fuel.mp3")
end PlayFuel

procedure stop
    Music.PlayFileStop
end stop

%Music Buttons
var Fuel := GUI.CreateButton (5, 500 - 125, 120, "Fuel", PlayFuel)
var sto := GUI.CreateButton (5, 325, 120, "Sound Stop", stop)
var qut := GUI.CreateButton (5, 350, 120, "Exit", GUI.Quit)

loop
    exit when GUI.ProcessEvent
end loop
Music.PlayFileStop


: