Music Player won't play
Author |
Message |
Inuspal
|
Posted: Thu Jan 15, 2009 2:45 pm Post subject: Music Player won't play |
|
|
I had asked for help on a music player a couple of weeks back. I took a different approach to it (one my teacher suggested) and everything works except the files won't actually play. Can anyone see why? Does anyone have a solution to this?
Turing: |
%.......Variables Etc.......
import GUI
View.Set ("graphics:600;400,nobuttonbar,position:center;middle")
colourback (183)
cls
var startupimg : int := Pic.FileNew ("MazikaStartupImage.jpg")
var DirID : int
var streamNumber : int
var filefolder : string
var fileName : string
var MP3Songs : flexible array 1 .. 0 of string
var files : flexible array 1 .. 0 of string
var totalEntries : int := 0
var nameTextField : int
var textBox : int
var buttonX, buttonY : int
buttonX := (maxx div 3) div 3
buttonY := 10
var exitButton, playButton : int
var buttonSize := maxx div 3
var RegularFont, TitleFont, OutstandingFont : int
RegularFont := Font.New ("Arial:11")
OutstandingFont := Font.New ("Arial:14:bold")
TitleFont := Font.New ("Courier:30:bold")
assert RegularFont > 0 and OutstandingFont > 0 and TitleFont > 0
%.......Procedures.......
%----Music Play PROCESS----
% process DoMusic
% loop
% Music.PlayFile (fileName)
% end loop
% end DoMusic
%
% fork DoMusic
% ----ChooseLine----
procedure ChooseLine (line : int)
%Music.PlayFile (fileName (line))
GUI.SetText (nameTextField, MP3Songs (line ))
%GUI.SetText (nameTextField, fileName)
end ChooseLine
% ----Music Play PROCEDURE----
procedure DoMusic2
var line : int
% get the filename from the nameTextField
fileName := GUI.GetText (nameTextField )
Music.PlayFile (fileName )
locate (1, 1)
put "Playing ", fileName
end DoMusic2
%----Maybe?----
procedure DoMusic3
fileName := GUI.GetText (nameTextField )
Music.PlayFileReturn (fileName )
locate (1, 1)
put "Playing ", fileName
end DoMusic3
procedure doNothing (filename : string)
%GUI.GetText (fileName)
end doNothing
%.......Main Program.......
% ----Startup Image----
Pic.Draw (startupimg, 0, 0, picCopy)
delay (1000)
cls
% ----"Get Folder" Page----
Font.Draw ("Mazika", 200, 360, TitleFont, white)
Font.Draw ("Enter the full address of a folder where you have music files located.", 5, 330, RegularFont, white)
Font.Draw ("*NOTE*", 5, 30, OutstandingFont, white)
Font.Draw ("The only compatible files are those with the extensions .mp3, .wav, and .midi", 85, 30, RegularFont, white)
colour (83)
locate (6, 4)
get filefolder
cls
% ----Find Compatible Music Files----
streamNumber := Dir.Open (filefolder )
assert streamNumber > 0
loop
fileName := Dir.Get (streamNumber )
totalEntries + = 1
exit when fileName = ""
end loop
%Dir.Close (streamNumber)
% Put them in a GUI box
new MP3Songs, totalEntries + 1
var fileCount : int := 1
loop
fileName := Dir.Get (streamNumber )
% GUI.AddLine(nameTextField, MP3Songs(fileCount))
exit when fileName = "" or fileCount > totalEntries
fileCount + = 1
end loop
GUI.SetBackgroundColour (183)
textBox := GUI.CreateTextBoxChoice (10, 75, maxx - 10, maxy - 85, GUI.INDENT, RegularFont, ChooseLine )
nameTextField := GUI.CreateTextFieldFull (10, 45, maxx - 20, "", doNothing, GUI.INDENT, RegularFont, 0)
playButton := GUI.CreateButton (buttonX, buttonY, buttonSize, "Play", DoMusic3 )
GUI.SetColour (playButton, 182)
exitButton := GUI.CreateButton (buttonX + buttonSize + 20, buttonY, buttonSize, "Close", GUI.Quit)
GUI.SetColour (exitButton, 182)
streamNumber := Dir.Open (filefolder )
assert streamNumber > 0
var count : int := 1
loop
MP3Songs (count ) := Dir.Get (streamNumber )
exit when MP3Songs (count ) = "" or count > totalEntries
GUI.AddLine (textBox, MP3Songs (count ))
count + = 1
end loop
Dir.Close (streamNumber )
loop
exit when GUI.ProcessEvent
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
The_Bean
|
Posted: Thu Jan 15, 2009 6:58 pm Post subject: Re: Music Player won't play |
|
|
You have to include the directory that the music is located in to the Music.Play line, right now it's looking in the directory that the program is located in for the music. |
|
|
|
|
|
Inuspal
|
Posted: Fri Jan 16, 2009 9:11 am Post subject: RE:Music Player won\'t play |
|
|
Ohhh that makes sense...but I tried it (I probably have the wrong syntax) and it didn't work. This is what I had:
Turing: |
% ----Music Play PROCEDURE----
procedure DoMusic2
var line : int
% get the filename from the nameTextField
fileName := GUI.GetText (nameTextField )
Music.PlayFile (filefolder "/"fileName )
locate (1, 1)
put "Playing ", fileName
end DoMusic2
|
|
|
|
|
|
|
|
|