curif / AgeOfJoy-2022.1

Age of Joy Unit V2022.1
13 stars 7 forks source link

Strange bug in `MusicAddList` #533

Open curif opened 1 month ago

curif commented 1 month ago

I thought it was working, but now I always get this runtime error: RUNTIME ERROR: music_playback_control.bas line: 125 Exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Program: music_playback_control.bas
RUNTIME ERROR: music_playback_control.bas 
 line: 125
Exception: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

---PROGRAM STATUS ---
PROGRAM: music_playback_control.bas
Last line parsed: #421
Next line to execute: > #111
Executed lines counter: 3
Lines per second: 22.55639
VARS: ----------------
VOLUME: 0 [Number]
PLAYLIST: Van Halen - Runnin' With The Devil.mp3:The Cars - Bye Bye Love.mp3:Van Halen - I'm The One.mp3:03 Life In The Fast Lane (2018_01_14 17_36_50 UTC).mp3:04 Wasted Time (2018_01_14 17_36_50 UTC).mp3:06 Victim Of Love (2018_01_14 17_36_50 UTC).mp3:Boston - More Than A Feeling.mp3:09 The Last Resort (2018_01_14 17_36_50 UTC).mp3:05 Wasted Time (Reprise) (2018_01_14 17_36_50 UTC).mp3:The Cars -  I'm in Touch With Your World.mp3:Boston - Smokin'.mp3:Boston - Something About You.mp3:Van Halen - Atomic Punk.mp3:Boston - Foreplay_Long Time.mp3:Van Halen - Feel Your Love Tonight.mp3:The Cars - You're All I've Got Tonight.mp3:Van Halen -  Ain't Talkin' 'Bout Love.mp3:08 Try And Love Again (2018_01_14 17_36_50 UTC).mp3:Van Halen - Jamie's Cryin'.mp3:Boston - Rock & Roll Band.mp3:Van Halen - Little Dreamer.mp3:The Cars - Good Times Roll.mp3:Boston - Hitch A Ride.mp3:The Cars - Don't Cha Stop.mp3:Van Halen - On Fire.mp3:The Cars - All Mixed Up.mp3:The Cars - My Best Friend's Girl.mp3:02 New Kid In Town (2018_01_14 17_36_50 UTC).mp3:Boston - Let Me Take You Home Tonight.mp3:The Cars - Moving in Stereo.mp3:Van Halen - Eruption_You Really Got Me.mp3:01 Hotel California (2018_01_14 17_36_50 UTC).mp3:The Cars - Just What I Needed.mp3:Van Halen - Ice Cream Man.mp3:07 Pretty Maids All In A Row (2018_01_14 17_36_50 UTC).mp3:Boston - Peace Of Mind.mp3 [String]

001  'In-Game Music Playback Control by crusher124

002  'This program will create a random playlist of all your music files and allow next and back skipping along with volume control, while playing a game in AOJ.  AOJ v0.5.5 required.

003  'Run this file from your cab description.yaml agebasic section, after-insert-coin.

011  'Press R-stick-CLICK + Left-stick-LEFT for previous track
012  'Press R-stick-CLICK + Left-stick-RIGHT for next track
013  'Press R-stick-CLICK + Y for volume UP
014  'Press R-stick-CLICK + X for volume DOWN
015  'Press R-stick-CLICK + Left-stick-CLICK to EXIT music playback control, playback will stop, there is no pause function.  Exit cab and restart to restart music playback control.

100  LET volume = 0  'set beginning volume to default
105  CALL MusicClear()  'clear music queue

110  LET playlist = GetFiles(MusicPath(), ":", 1)  'create random (all files) playlist
125  CALL MusicAddList(playlist, ":")  'add the playlist to queue
130  CALL MusicLoop(1)  'auto-loop queue, set to (0) for no looping
135  CALL MusicReset()  'start queue playback

140  IF AND(ControlActive(JOYPAD_LEFT), ControlActive(JOYPAD_R3)) THEN CALL MusicPrevious()  'previous track
145  IF AND(ControlActive(JOYPAD_RIGHT), ControlActive(JOYPAD_R3)) THEN CALL MusicNext()  'next track
150  IF AND(ControlActive(JOYPAD_Y), ControlActive(JOYPAD_R3)) THEN GOSUB 200  'volume UP
155  IF AND(ControlActive(JOYPAD_X), ControlActive(JOYPAD_R3)) THEN GOSUB 300  'volume DOWN
160  IF AND(ControlActive(MOUSE_BUTTON_4), ControlActive(JOYPAD_R3)) THEN GOTO 400  'EXIT

170  GOTO 140  'return to polling

200  LET volume = volume + 1  'increase volume
210  IF volume > 20 THEN LET volume = 20  'max volume is 20dB
220  CALL AudioMusicSetVolume(volume)  'set volume
240  RETURN

300  LET volume = volume - 1  'decrease volume
310  IF volume < -80 THEN LET volume = -80  'min volume is -80dB, silent
320  CALL AudioMusicSetVolume(volume)  'set volume
340  RETURN

400  CALL MusicClear()  'clear music queue
405  LET volume = 0  'reset volume to default
410  CALL AudioMusicSetVolume(0)  'reset default music volume
415  LET playlist = 0  'clear playlist
420  END  'exit Music_Playback_Control.bas