import GUI
var cdWindow : int := Window.Open ("graphics:900;300")
var cdBack : int := Pic.FileNew ("cdBack.jpg")
var streamNumber : int
var fileName : string
var maxTracks : int := 0
var cdDrive : string
var track : int := 1
var currentTrack : string := "cd:" + intstr (track)
var fontID : int := Font.New ("verdana:10")
var playPic : int := Pic.FileNew ("play.jpg")
var stopPic : int := Pic.FileNew ("stop.jpg")
var nextPic : int := Pic.FileNew ("next.jpg")
var prevPic : int := Pic.FileNew ("previous.jpg")
var playButton : int
var stopButton : int
var nextTrack : int
var previousTrack : int
var quitButton : int
var playing : boolean := false
var cdDriveField, cdDriveLabel : int
var trackID : int := Font.New ("verdana:30")
process playTrack
Music.PlayFile (currentTrack)
end playTrack
procedure playMusic
playing := true
fork playTrack
end playMusic
procedure stopMusic
Music.PlayFileStop
playing := false
end stopMusic
procedure next
Music.PlayFileStop
if track = maxTracks then
track := maxTracks
Draw.FillBox (340, maxy div 2 - 30, 340 + Font.Width ("Track: " + intstr (track), trackID), maxy div 2 + 40, darkgrey)
Font.Draw ("Track: " + intstr (track), 340, maxy div 2 - 30, trackID, 43)
else
track += 1
Draw.FillBox (340, maxy div 2 - 30, 340 + Font.Width ("Track: " + intstr (track), trackID), maxy div 2 + 40, darkgrey)
Font.Draw ("Track: " + intstr (track), 340, maxy div 2 - 30, trackID, 43)
end if
currentTrack := "cd:" + intstr (track)
if playing then
fork playTrack
else
end if
end next
procedure previous
Music.PlayFileStop
if track = 1 then
track := 1
Draw.FillBox (340, maxy div 2 - 30, 340 + Font.Width ("Track: " + intstr (track), trackID), maxy div 2 + 40, darkgrey)
Font.Draw ("Track: " + intstr (track), 340, maxy div 2 - 30, trackID, 43)
else
track -= 1
Draw.FillBox (340, maxy div 2 - 30, 340 + Font.Width ("Track: " + intstr (track), trackID), maxy div 2 + 40, darkgrey)
Font.Draw ("Track: " + intstr (track), 340, maxy div 2 - 30, trackID, 43)
currentTrack := "cd:" + intstr (track)
end if
if playing then
fork playTrack
else
end if
end previous
procedure closeWindow
quit
end closeWindow
procedure error (text : string)
GUI.Dispose (cdDriveField)
GUI.Dispose (cdDriveLabel)
var key : string (1)
Font.Draw (text, 340, maxy div 2, trackID, 43)
Font.Draw ("Press Any Key", 360, maxy div 2 - 30, fontID, 43)
getch (key)
quit
end error
procedure inputText (text : string)
if text = "c" or text = "C" then
error ("That's not the cd drive.")
else
var dirCheck : int
dirCheck := Dir.Open (text + ":\\")
if dirCheck = 0 then
error ("Drive Does Not Exist")
closeWindow
else
streamNumber := Dir.Open (text + ":")
fileName := Dir.Get (streamNumber)
if index (fileName (* -4 .. *), ".cda") not= 0 then
loop
fileName := Dir.Get (streamNumber)
exit when fileName = ""
maxTracks += 1
end loop
Dir.Close (streamNumber)
GUI.Dispose (cdDriveField)
GUI.Dispose (cdDriveLabel)
Pic.Draw (cdBack, 0, 0, picMerge)
Draw.FillBox (340, maxy div 2 - 30, 340 + Font.Width ("Track: " + intstr (track), trackID), maxy div 2 + 40, darkgrey)
Font.Draw ("Track: " + intstr (track), 340, maxy div 2 - 30, trackID, 43)
playButton := GUI.CreatePictureButtonFull (120, 100, playPic, playMusic, 0, 0, "'", true)
stopButton := GUI.CreatePictureButtonFull (600, 100, stopPic, stopMusic, 0, 0, "'", true)
nextTrack := GUI.CreatePictureButtonFull (120, 50, nextPic, next, 0, 0, "/", true)
previousTrack := GUI.CreatePictureButtonFull (600, 50, prevPic, previous, 0, 0, "/", true)
quitButton := GUI.CreateButtonFull (360, 10, 0, "Quit", closeWindow, 0, "/", true)
else
error ("Invalid CD in Drive " + text + ":\\.")
end if
Dir.Close (dirCheck)
end if
end if
end inputText
procedure startScreen
Pic.Draw (cdBack, 0, 0, picMerge)
cdDriveField := GUI.CreateTextFieldFull (maxx div 2 + 100, 230, 100, "", inputText, GUI.INDENT, fontID, GUI.ANY)
cdDriveLabel := GUI.CreateLabelFull (maxx div 2, 230, "CD Drive: ", 0, 0, GUI.LEFT, fontID)
end startScreen
startScreen
loop
exit when GUI.ProcessEvent
end loop
|