Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Having trouble stoping a "fork"
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
timtimpei




PostPosted: Sat Jan 12, 2008 4:18 pm   Post subject: Having trouble stoping a "fork"

i want to put music into my program, so i did this:

Quote:


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

Quote:
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? Confused
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Sat Jan 12, 2008 4:35 pm   Post subject: RE:Having trouble stoping a "fork"

Did you ensure your other music was stopped? Check into Music.Stop()
Tony




PostPosted: Sat Jan 12, 2008 5:27 pm   Post subject: RE:Having trouble stoping a "fork"

The reason this doesn't work is that Music.PlayFile has a loop of it's own. This this out:
code:

Music.PlayFile("bgmusic1.wav")
put "done playing"


I think you were aiming at something along the lines of
code:

Music.PlayFileReturn(welcome_music)
loop
   exit when finished
end loop

Though I think Clayton has a more proper solution.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ericfourfour




PostPosted: Sat Jan 12, 2008 6:10 pm   Post subject: RE:Having trouble stoping a "fork"

Play music: Music.PlayFileReturn("music file name")
Stop music: Music.PlayFileStop

Check the Music module section of the Turing Documentation.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: