concurrency
Author |
Message |
jrok311
|
Posted: Fri Apr 01, 2005 10:53 am Post subject: concurrency |
|
|
I need to make a program that plays music at the same time as running a process using a fork because when I play music now it disables all other buttons. Here is my code.
code: |
import GUI in "%oot/support/lib/GUI"
%procedures
forward proc music
procedure frenchmusic
Music.PlayFile ("ADD .MID FILE HERE")
end frenchmusic
body proc music
locatexy (50, 400)
cls
put "Choose a song to play"
var frenchsong : int := GUI.CreateButton (50, 200, 120, "french song", frenchmusic)
var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)
end music
%main function
procedure main
Window.Set (defWinId, "title:J-ROK's Media Centre 2005")
setscreen ("graphics:700, 500;nobuttonbar")
colourback (30)
cls
var font1 : int
var font2 : int
font1 := Font.New ("serif:20")
font2 := Font.New ("Comic Sans MS:10")
Font.Draw ("J-ROK's Media Centre 2005", 200, 450, font1, blue)
Font.Draw ("Choose an option to get started", 260, 430, font2, blue)
var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)
end main
%end of main function
main
loop
exit when GUI.ProcessEvent
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Apr 01, 2005 11:01 am Post subject: (No subject) |
|
|
|
|
|
|
|
![](images/spacer.gif) |
jrok311
|
Posted: Fri Apr 01, 2005 11:09 pm Post subject: concurrency |
|
|
that doesnt work, the first part goes blue so its not one of those turing things. |
|
|
|
|
![](images/spacer.gif) |
RaPsCaLLioN
![](http://www.woodus.com/den/gallery/graphics/dw2nes/animated/dw2-hero.gif)
|
Posted: Sat Apr 02, 2005 9:48 am Post subject: (No subject) |
|
|
I think ur problem is with that main procedure. Mainline code should just be a loop. And Music.PlayFileReturn is the command u want....
code: | import GUI in "%oot/support/lib/GUI"
%procedures
forward proc music
procedure frenchmusic
Music.PlayFileReturn ("ADD FILE HERE")
end frenchmusic
body proc music
locatexy (50, 400)
cls
put "Choose a song to play"
var frenchsong : int := GUI.CreateButton (50, 200, 120, "french song", frenchmusic)
var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)
end music
%*** MAINLINE ***
Window.Set (defWinId, "title:J-ROK's Media Centre 2005")
setscreen ("graphics:700, 500;nobuttonbar")
colourback (30)
cls
var font1 : int
var font2 : int
font1 := Font.New ("serif:20")
font2 := Font.New ("Comic Sans MS:10")
Font.Draw ("J-ROK's Media Centre 2005", 200, 450, font1, blue)
Font.Draw ("Choose an option to get started", 260, 430, font2, blue)
var musicbutton : int := GUI.CreateButton (50, 20, 120, "Music", music)
loop
locate (1, 1)
put Rand.Int (1, 10)
delay (100)
exit when GUI.ProcessEvent
end loop |
|
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Sat Apr 02, 2005 12:50 pm Post subject: (No subject) |
|
|
Quote: that doesnt work, the first part goes blue so its not one of those turing things.
r u sure u typed it rite??
it worx fine for me |
|
|
|
|
![](images/spacer.gif) |
Neo
![](http://compsci.ca/v3/uploads/user_avatars/441131374462fea7633fd3.gif)
|
Posted: Sat Apr 02, 2005 2:01 pm Post subject: (No subject) |
|
|
He must have an earlier version. |
|
|
|
|
![](images/spacer.gif) |
lordofall
|
Posted: Sat Apr 02, 2005 11:40 pm Post subject: (No subject) |
|
|
y are u using processes they so sloppy instead use GUI.SetNullEventHandler, its really badly documented but basically it works like this
procedure controlMusic
end controlMusic
GUI.SetNullEventHandler(controlMusic)
now whenever no buttons are being clicked it will execute the action procedure control music, though ur gonna havta figure out the code to keep checking the music or playing it from a certain spot (unless it automatically does that) well good luck. |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Sun Apr 03, 2005 11:06 am Post subject: (No subject) |
|
|
y r processes sloppy for music?? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
jrok311
|
Posted: Sun Apr 03, 2005 11:34 am Post subject: fixed |
|
|
I found a solution to my problem. I called the procedure with a fork in it for another process, I made that process played the music. Thanks for all your help. |
|
|
|
|
![](images/spacer.gif) |
lordofall
|
Posted: Sun Apr 03, 2005 2:09 pm Post subject: (No subject) |
|
|
i just thought nullevent handelers better because instead of randomly going back and forth to the music it would play the music whenever nothing is going on with the user tho i guess a human ear wouldn't detect the process. |
|
|
|
|
![](images/spacer.gif) |
|
|