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

Username:   Password: 
 RegisterRegister   
 music help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Thuged_Out_G




PostPosted: Thu Dec 25, 2003 1:25 am   Post subject: music help

code:

import GUI

var win := Window.Open ("title:My Media Player,position:top;center,graphics:200;400")
proc stop
    Music.PlayFileStop
end stop

proc playCd
    Music.PlayFile ("cd")
end playCd

proc playTrack1
    Music.PlayFile ("cd:1")
end playTrack1

proc playTrack2
    Music.PlayFile ("cd:2")
end playTrack2

proc playTrack3
    Music.PlayFile ("cd:3")
end playTrack3

proc playTrack4
    Music.PlayFile ("cd:4")
end playTrack4

proc playTrack5
    Music.PlayFile ("cd:5")
end playTrack5

proc playTrack6
    Music.PlayFile ("cd:6")
end playTrack6

proc playTrack7
    Music.PlayFile ("cd:7")
end playTrack7

proc playTrack8
    Music.PlayFile ("cd:8")
end playTrack8

proc playTrack9
    Music.PlayFile ("cd:9")
end playTrack9

proc playTrack10
    Music.PlayFile ("cd:10")
end playTrack10

proc playTrack11
    Music.PlayFile ("cd:11")
end playTrack11

proc playTrack12
    Music.PlayFile ("cd:12")
end playTrack12

proc playTrack13
    Music.PlayFile ("cd:13")
end playTrack13

proc playTrack14
    Music.PlayFile ("cd:14")
end playTrack14

proc playTrack15
    Music.PlayFile ("cd:15")
end playTrack15

proc playTrack16
    Music.PlayFile ("cd:16")
end playTrack16

proc playTrack17
    Music.PlayFile ("cd:17")
end playTrack17

proc playTrack18
    Music.PlayFile ("cd:18")
end playTrack18

proc playTrack19
    Music.PlayFile ("cd:19")
end playTrack19

proc playTrack20
    Music.PlayFile ("cd:20")
end playTrack20

var playAll : int := GUI.CreateButtonFull (1, 350, 0, "ALL       ", playCd, 0, '^D', true)
var playstop : int := GUI.CreateButtonFull (80, 350, 0, "STOP   ", stop, 0, '^D', true)
var play1 : int := GUI.CreateButtonFull (1, 320, 0, "Track1  ", playTrack1, 0, '^D', true)
var play2 : int := GUI.CreateButtonFull (1, 290, 0, "Track2  ", playTrack2, 0, '^D', true)
var play3 : int := GUI.CreateButtonFull (1, 260, 0, "Track3  ", playTrack3, 0, '^D', true)
var play4 : int := GUI.CreateButtonFull (1, 230, 0, "Track4  ", playTrack4, 0, '^D', true)
var play5 : int := GUI.CreateButtonFull (1, 200, 0, "Track5  ", playTrack5, 0, '^D', true)
var play6 : int := GUI.CreateButtonFull (1, 170, 0, "Track6  ", playTrack6, 0, '^D', true)
var play7 : int := GUI.CreateButtonFull (1, 140, 0, "Track7  ", playTrack7, 0, '^D', true)
var play8 : int := GUI.CreateButtonFull (1, 110, 0, "Track8  ", playTrack8, 0, '^D', true)
var play9 : int := GUI.CreateButtonFull (1, 80, 0, "Track9  ", playTrack9, 0, '^D', true)
var play10 : int := GUI.CreateButtonFull (1, 50, 0, "Track10", playTrack10, 0, '^D', true)
var play11 : int := GUI.CreateButtonFull (80, 320, 0, "Track11", playTrack11, 0, '^D', true)
var play12 : int := GUI.CreateButtonFull (80, 290, 0, "Track12", playTrack12, 0, '^D', true)
var play13 : int := GUI.CreateButtonFull (80, 260, 0, "Track13", playTrack13, 0, '^D', true)
var play14 : int := GUI.CreateButtonFull (80, 230, 0, "Track14", playTrack14, 0, '^D', true)
var play15 : int := GUI.CreateButtonFull (80, 200, 0, "Track15", playTrack15, 0, '^D', true)
var play16 : int := GUI.CreateButtonFull (80, 170, 0, "Track16", playTrack16, 0, '^D', true)
var play17 : int := GUI.CreateButtonFull (80, 140, 0, "Track17", playTrack17, 0, '^D', true)
var play18 : int := GUI.CreateButtonFull (80, 110, 0, "Track18", playTrack18, 0, '^D', true)
var play19 : int := GUI.CreateButtonFull (80, 80, 0, "Track19", playTrack19, 0, '^D', true)
var play20 : int := GUI.CreateButtonFull (80, 50, 0, "Track20", playTrack20, 0, '^D', true)

colorback(black)

    loop
        exit when GUI.ProcessEvent
    end loop



ok i have a few problems i cant figure out

1)the background doesnt seem to go black, any help?
2)i cant figure out how you can click more then one button, after i click one button it says program finished
3)is there a way to read the CD and find how many tracks are on it?
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Thu Dec 25, 2003 10:07 am   Post subject: (No subject)

code:
var win := Window.Open ("title:My Media Player,position:top;center,graphics:200;400")

colorback (black)
cls


have your colorback command at the beginning, and cls to show the background color.

the reason the button is only clicked once and the program is finished is because you only assigned it once. Declare all the variables outside the loop, and in the loop, assign the variables their respective value. That should work.

lastly, unless you can somehow check to see how big of a file is each song from a CD with Turing, then I don't think you can tell how many songs are on there.
Thuged_Out_G




PostPosted: Thu Dec 25, 2003 3:31 pm   Post subject: (No subject)

thanks asian Very Happy
Thuged_Out_G




PostPosted: Thu Dec 25, 2003 5:45 pm   Post subject: (No subject)

ok, everything works good except one thing

the buttons dont work if a song is playing, is there any way around this?

example, if i click track 1, i cant click another button until track 1 is finished
AsianSensation




PostPosted: Thu Dec 25, 2003 10:46 pm   Post subject: (No subject)

I guess you have to set a flag or something to exit that procedure. right now, when you are playing a song, it will keep playing because it's not a process and doesn't happen simultaneously with the program. I don't know if you can put a process inside a GUI button, I'm not even sure you can put a process into a procedure. so there really is no way of stopping the song.

btw, I think I might have a way to check to see how many song there are on the CD. since you are using strings for the path anyways, just add some string manipulation.

instead of:

code:
Music.PlayFile ("cd:3")


try this

code:
Music.PlayFile ("cd:" + intstr (some number here))


maybe that would work? I'm assuming the Music.PlayFile returns false when there isn't anything to play.
Thuged_Out_G




PostPosted: Thu Dec 25, 2003 11:21 pm   Post subject: (No subject)

i will try out the intstr, would it work something like this?
code:

for i:1..100
Music.PlayFile("cd: " + intstr(i))
end for


im not positive on how to make the song and the program run simultaneously....would it e something along these lines:

code:

process main
the main program here
end main

process playTrackOne
Music.PlayFile("cd:1")
end playTrackOne

fork main
fork playTrackOne
AsianSensation




PostPosted: Fri Dec 26, 2003 1:55 pm   Post subject: (No subject)

yep, intstr works like that.

also, I'm not sure if you could substitute process for precedures when it comes to GUI. I suggest have an access procedure.

like this:
code:
process song1
    loop
        Music.PlayFile ("cd:1")
    end loop
end song1

proc playsong1
    Music.PlayFileStop
    fork song1
end playsong1


something like that. and in your GUI buttons, just call the playsong1 procedure. Music.PlayFileStop is to stop all other music from playing when you are accessing the current song.

btw, when running music simultaneously with the program, you don't need to fork the main line, there is no point in doing that.
Thuged_Out_G




PostPosted: Fri Dec 26, 2003 2:38 pm   Post subject: (No subject)

ok, thanks again asian Very Happy
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: