Computer Science Canada

song player

Author:  r.m_spy [ Sun Dec 02, 2007 9:37 am ]
Post subject:  song player

plays any cd up to eveven



var song:int
put"enter in your song #"
get song
cls
drawfillbox(0,0,maxx,maxy,black)
drawfilloval(maxx div 2,maxy div 2,maxx div 2,maxy div 2,white)
var announceFont : int := Font.New ("Sanserif:50:bold")
procedure CentreFont (s : string, x, y, f, clr : int)
var w : int := Font.Width (s, f)
Font.Draw (s, x - w div 2, y, f, clr)
end CentreFont
CentreFont("song",maxx div 2,maxy div 2,announceFont,brightred)
if song=1 then
CentreFont("1",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:1")
elsif song=2 then
CentreFont("2",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:2")
elsif song=3 then
CentreFont("3",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:3")
elsif song=4 then
CentreFont("4",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:4")
elsif song=5 then
CentreFont("5",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:5")
elsif song=6 then
CentreFont("6",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:6")
elsif song=7 then
CentreFont("7",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:7")
elsif song=8 then
CentreFont("8",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:8")
elsif song=9 then
CentreFont("9",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:9")
elsif song=10 then
CentreFont("10",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:10")
elsif song=11 then
CentreFont("11",maxx div 2,maxy div 2-100,announceFont,brightred)
Music.PlayFile ("cd:11")
end if

Author:  Ultrahex [ Sun Dec 02, 2007 12:42 pm ]
Post subject:  Re: song player

I am not sure how useful this program is, but here is where i will go with this:

SOOO much repetitive code... infact you could make this a x # of song player almost instantly.\ and also can choose another song while its playing!

Turing:

procedure CentreFont (s : string, x, y, f, clr : int)
    var w : int := Font.Width (s, f)
    Font.Draw (s, x - w div 2, y, f, clr)
end CentreFont

loop
    var song : int
    put "enter in your song #"
    get song
    Music.PlayFileStop
    cls

    drawfillbox (0, 0, maxx, maxy, black)
    drawfilloval (maxx div 2, maxy div 2, maxx div 2, maxy div 2, white)

    var announceFont : int := Font.New ("Sanserif:50:bold")

    CentreFont ("song", maxx div 2, maxy div 2, announceFont, brightred)
    CentreFont (intstr (song), maxx div 2, maxy div 2 - 100, announceFont, brightred)
    Music.PlayFileReturn ("cd:" + intstr (song))
end loop



: