
-----------------------------------
timtimpei
Sat Jan 12, 2008 4:18 pm

Having trouble stoping a &quot;fork&quot;
-----------------------------------
i want to put music into my program, so i did this:



finished := false

process bgmusic (welcome_music : string)
    loop
        Music.PlayFile (welcome_music)
        exit when finished
    end loop
end bgmusic

procedure welcome_screen
     fork bgmusic ("bgmusic1.wav")
     (all my other codes)
end welcome_screen

welcome_screen

then i want to play another music on another screen, so i did this:

finished := false

process bgmusic (welcome_music : string)
    loop
        Music.PlayFile (welcome_music)
        exit when finished
    end loop
end bgmusic

procedure welcome_screen
     fork bgmusic ("bgmusic1.wav")
     (all my other codes)
end welcome_screen

procedure menu
     finished:=false
     fork bgmusic ("menusong.wav")

     (other codes)
end menu

welcome_screen
finished:=true
menu

when i ran the program, the menu procedure played both songs. How can i prevent this without making another process? :?

-----------------------------------
Clayton
Sat Jan 12, 2008 4:35 pm

RE:Having trouble stoping a &quot;fork&quot;
-----------------------------------
Did you ensure your other music was stopped? Check into Music.Stop()

-----------------------------------
Tony
Sat Jan 12, 2008 5:27 pm

RE:Having trouble stoping a &quot;fork&quot;
-----------------------------------
The reason this doesn't work is that Music.PlayFile has a loop of it's own. This this out:

Music.PlayFile("bgmusic1.wav")
put "done playing"


I think you were aiming at something along the lines of

Music.PlayFileReturn(welcome_music)
loop
   exit when finished
end loop

Though I think Clayton has a more proper solution.

-----------------------------------
ericfourfour
Sat Jan 12, 2008 6:10 pm

RE:Having trouble stoping a &quot;fork&quot;
-----------------------------------
Play music: Music.PlayFileReturn("music file name")
Stop music: Music.PlayFileStop

Check the Music module section of the Turing Documentation.
