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

Username:   Password: 
 RegisterRegister   
 GUI.ScrollBar = My Devil XS
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Prince Pwn




PostPosted: Wed Dec 20, 2006 8:03 pm   Post subject: GUI.ScrollBar = My Devil XS

I could never get the built in GUI.ScrollBar to work in my favor. I got pretty far with it this time, but I wish to display all my songs so I could actually have them go offscreen when I say scroll up, then have them re-appear when I scroll back down. The program I have right now just displays one song but scrolls through them and plays. The ScrollBar is evil to me.

code:

%%%THE Media Player%%%
import GUI

View.Set ("graphics;offscreenonly")

var dir : string := "C:/Documents and Settings/" + Sys.GetUserName + "/My Documents/My Music/"
Dir.Change (dir)
var stream : int := Dir.Open (dir)
var counter, scrollBar : int := 0
var filenameStorage : array 1 .. 200 of string
var filename, currentSong : string := ""

for i : 1 .. stream
    filename := Dir.Get (stream)
    exit when filename = ""
    if filename (length (filename)) = '3' then
        counter += 1
        filenameStorage (counter) := filename
    end if
end for

procedure ScrollBarMoved (value : int)
    if value > 0 then
        currentSong := filenameStorage (value)
        Music.PlayFileStop
        Music.PlayFileReturn (currentSong)
    end if
end ScrollBarMoved

scrollBar := GUI.CreateVerticalScrollBar (maxx - 20, 10, maxy - 20,
    0, counter, 0, ScrollBarMoved)

var welcomeFont : int := Font.New ("MS Sans Serif:20")
var songFont : int := Font.New ("Comic Sans MS:15")
loop
    exit when GUI.ProcessEvent
    Draw.FillBox (0, 0, maxx, maxy, black)
    Font.Draw ("Welcome to THE Media Player!", 120, maxy - 40, welcomeFont, white)
    if currentSong not= "" then
        Font.Draw ("Playing " + currentSong, 150, maxy - 80, songFont, brightred)
    end if
    GUI.Refresh
    View.Update
    cls
end loop
Sponsor
Sponsor
Sponsor
sponsor
Prince Pwn




PostPosted: Wed Dec 20, 2006 8:08 pm   Post subject: (No subject)

Also if I have like 6 folders inside my directory eg: a folder for albums, how would I grab all the mp3s out of them and add them into my array? I know of Dir.Get but how could I go into the existing folders in C:/..My Music/ then leave them and go to the next?

C:/ .... My Music/
song1.mp3
song2.mp3
song3.mp3
song4.mp3
-------------------------> Band1Folder/
song5.mp3
song6.mp3
-------------------------> Band2Folder/
song7.mp3
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  [ 2 Posts ]
Jump to:   


Style:  
Search: