Okay, so for some reason, whenever I use the Pause Music command in my program, the whole thing freezes. I havent had this problem with stop music, play music, any of those. Just this one command. Any suggestions?
very simple code, there should be no problem with it
if spacekey() = 1 then pause music 1
heres the whole program as of now, in case you need to look at it for some reason. not very clean, but im still trying to get the basics of it working, so i'll get to making it look tidy later.
Rem Project: MusicPlayer
Rem Created: Saturday, July 10, 2010
Rem ***** Main Source File *****
Type songItem
title as string
artist as string
album as string
genre as string
year as string
composer as string
length
num
filename as string
filetype as string
filelocation as string
endtype
global song as string
global artist as string
global album as string
global genre as string
global year as string
global composer as string
global duration
global trackNum
global paused
global startTime
global currentTime
global libcnt //library count, # of songs
baseMusicDirectory as String
baseMusicDirectory = "C:\Documents and Settings\Matt Balmer\My Documents\My Music\"
libcnt = 1
dim songs(libcnt) as songItem
songs(1).title = "Sound of Madness"
songs(1).artist = "Shinedown"
songs(1).album = "Sound of Madness"
songs(1).genre = "Rock/Metal"
songs(1).year = "2008"
songs(1).composer = "Brent Smith"
songs(1).length = 235
songs(1).num = 2
songs(1).filename = "02 Sound of Madness"
songs(1).filetype = "wma"
songs(1).filelocation = baseMusicDirectory+songs(1).artist+"\"+songs(1).album+"\"+songs(1).filename+"."+songs(1).filetype
set dir baseMusicDirectory
//perform checklist for files
`for t=1 to checklist quantity()
`print "files= "+checklist string$(t)
`next t
for r = 1 to libcnt
print r
fileLocation$ = songs(r).filelocation
print fileLocation$
if file exist(fileLocation$) = 0
print "File does not exist"
else
print "Loading file"
endif
load music fileLocation$,r
next r
//print "Press any key to continue"
//wait key
cls
do
for r = 1 to libcnt
play music r
startTime = timer()
repeat
cls
display(r)
keyCheck(r)
if spacekey() = 1 then pause music 1
`if music paused(r) = 1 then center text 512,50, "PAUSED"
until music playing(r) = 0
next r
loop
function display(r)
print songs(r).title
print songs(r).artist
print songs(r).album
minutes = (songs(r).length / 60)
seconds = songs(r).length - (minutes*60)
currentTime = timer() - startTime
curSec = currentTime/1000
curMin = curSec / 60
remSec = curSec - (curMin*60)
percentBar(minutes,seconds)
print str$(curMin)+":"+timeFormat(remSec)+" / "+str$(minutes)+":"+timeFormat(seconds)
print
print songs(r).composer
print songs(r).year
print songs(r).genre
print
endfunction
function keyCheck(r)
remstart if spacekey() = 1 and keydown = 0
keydown = 1
if music paused(r) = 0
pause music r
endif
if music paused(r) = 1
play music r
endif
endif remend
if inkey$() = ""
keydown = 0
endif
endfunction
function timeFormat(seconds)
if seconds < 10
txt$ = "0" + str$(seconds)
else
txt$ = str$(seconds)
endif
endfunction txt$
function percentBar(tm,ts)
ts = ts + (tm * 60)
percent# = (currentTime+0.0) / (ts*1000+0.0)
`print str$(formatDecimal(percent#*100,4))+"%"
print formatDecimalToString(percent#*100,2)+"%"
ink rgb(255,255,255),0
box 8,198,1012,252
ink rgb(0,0,0),0
box 10,200,1010,250
ink rgb(percent#*255,0,(1-percent#)*255),0
box 10,200,10+percent#*1000,250
ink rgb(255,255,255),0
endfunction
function formatDecimal(dec#,places)
print dec#
temp = dec# * (10^places)
print temp
result# = (temp+0.0) / ((10^places)+0.0)
print result#
endfunction result#
function formatDecimalToString(dec#,places)
//print dec#
temp = dec# * (10^places)
//print temp
result# = (temp+0.0) / ((10^places)+0.0)
//print result#
rs$ = str$(result#)
loc = find first char$(rs$,".")
before$ = left$(rs$,loc)
after$ = right$(rs$,len(rs$)-loc)
after$ = left$(after$,places)
resultString$ = before$+after$
endfunction resultString$