
-----------------------------------
jrok311
Fri Apr 01, 2005 10:53 am

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.


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


-----------------------------------
Tony
Fri Apr 01, 2005 11:01 am


-----------------------------------

Music.PlayFileReturn ("ADD .MID FILE HERE") 


-----------------------------------
jrok311
Fri Apr 01, 2005 11:09 pm

concurrency
-----------------------------------
that doesnt work, the first part goes blue so its not one of those turing things.

-----------------------------------
RaPsCaLLioN
Sat Apr 02, 2005 9:48 am


-----------------------------------
I think ur problem is with that main procedure.  Mainline code should just be a loop.  And Music.PlayFileReturn is the command u want....

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

-----------------------------------
person
Sat Apr 02, 2005 12:50 pm


-----------------------------------
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

-----------------------------------
Neo
Sat Apr 02, 2005 2:01 pm


-----------------------------------
He must have an earlier version.

-----------------------------------
lordofall
Sat Apr 02, 2005 11:40 pm


-----------------------------------
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.

-----------------------------------
person
Sun Apr 03, 2005 11:06 am


-----------------------------------
y r processes sloppy for music??

-----------------------------------
jrok311
Sun Apr 03, 2005 11:34 am

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.

-----------------------------------
lordofall
Sun Apr 03, 2005 2:09 pm


-----------------------------------
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.
