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

Username:   Password: 
 RegisterRegister   
 How to stop a music file after the mouse is clicked? Thx for helping
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lamentoes




PostPosted: Thu May 29, 2008 7:44 pm   Post subject: How to stop a music file after the mouse is clicked? Thx for helping

Turing:

process DoMusic
    loop
      if B = 1 and (X > 402 and X < 499) and (Y > 273 and Y < 347) then
            cls
            Music.PlayFileStop
            exit
        end if
        Music.PlayFile ("Opening.mp3")
    end loop
end DoMusic
process mouse
    loop
        mousewhere (X, Y, B)
        locate (2, 3)
        put X, ",", Y, ",", B
        if B = 1 and (X > 402 and X < 499) and (Y > 273 and Y < 347) then
            cls
            exit
        end if
    end loop
end mouse

fork DoMusic
fork mouse


this is basically wut i hav but iafter i click the mouse the music does not stop..i think it is because the music is kinda long (1min), so the program is still reading the "Music.PlayFile ("Opening.mp3")" part
is there a way to solve it? please help.
Thanks !

MOD EDIT:Remember your syntax tags!
Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Sun Jun 01, 2008 9:22 am   Post subject: RE:How to stop a music file after the mouse is clicked? Thx for helping

I think it's best to combine the two and put them in one loop. Try to avoid forks and processes unless it's for background music.
Insectoid




PostPosted: Sun Jun 01, 2008 5:47 pm   Post subject: RE:How to stop a music file after the mouse is clicked? Thx for helping

I would not recommend using the mouse in a proccess, that will REALLY screw up the rest of your program.

On to fixing things.

If you click the mouse while the music is playing, DoMusic is still at this point:

code:

Music.PlayFile ("Opening.mp3")


Unless you click exactly when the program is executing the if statement, it will not work.

Andrew- Same thing. If they're in the same loop, it will not execute the Mouse.Where until the song has finished, where you will have less than a second to click.

I think you should find a way to end a process (If that's possible...). If the mouse is clicked, then end DoMusic.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: