We were given a basic program that just played the song when the program started and nothing else. I added a Play/Restart button which works if the song is currently playing but after the song ends it doesn't. I set it up to Pause/Resume when you press the Space Key. It pauses fine but will not resume. I also added Mute, Un-Mute, Volume Up, Volume Down, and instructions which all work fine.
If you know why the Play/Restart or Pause/Resume isn't working the way I want it to I would greatly appreciate it. My code is here:
cls
set window size 400,400
load music "CodeMonkey.mp3",1
`The above initializes the program by clearing the screen, setting the display size and loading the music file
line 0,50,650,50
line 0,55,650,55
line 325,0,325,350
set text size 50
center text 150,5, "Action"
center text 475,5, "Key"
set text size 27
line 0,100,650,100
center text 150,65, "Play/Restart"
center text 475, 65, "P"
line 0,150,650,150
center text 150,115, "Pause/Resume"
center text 475, 115, "Space Bar"
line 0,200,650,200
center text 150,165, "Mute"
center text 475, 165, "M"
line 0,250,650,250
center text 150,215, "Un-Mute"
center text 475, 215, "U"
line 0,300,650,300
center text 150,265, "Volume Up"
center text 475, 265, "Up Arrow"
line 0,350,650,350
center text 150,315, "Volume Down"
center text 475, 315, "Down Arrow"
set text size 70
center text 325,375, "Code Monkey"
`The above draws the instructions box
play music 1
soundVal# = 1
set music volume 1, soundVal#
`The above sets up the volume control and starts the music
while music playing (1) = 1
`The above makes sure the following only works while the music is playing
if upkey() = 1
soundVal# = soundVal# + .1
set music volume 1, soundVal#
endif
`The above ups the volume when the up key is pressed
if downkey() = 1
soundVal# = soundVal# - .1
set music volume 1, soundVal#
endif
`The above lowers the volume when the up key is pressed
if keystate(50) = 1
set music volume 1, 0
endif
`The above mutes the volume when the M key is pressed
if keystate(22) = 1
set music volume 1, soundVal#
endif
`The above unmutes the volume when the U key is pressed
if SpaceKey() = 1
Pause music 1
endif
`The above pauses the music when the Space key is pressed
if keystate(25) = 1
stop music 1
wait 1
play music 1
endif
`The above restarts the music from the beginning
endwhile
while music playing (1) = 0 or music paused(1) = 1
`The above makes sure the following only works while the music is not playing
if SpaceKey() = 1
Resume music 1
endif
`The above unpauses the music when the Space key is pressed
if keystate(25) = 1
play music 1
endif
`The above restarts the music from the beginning
endwhile
while music paused(1) = 1
if SpaceKey() = 1
resume music 1
endif
endwhile
do
if keystate(25) = 1
play music 1
endif
loop