Building my own mp3 player in MMBasic

Hi :slight_smile:
Thanks for your reply. I reworked my code myself a few days ago and added a path variable for the music folder too. I added a Cover view and a better refresh (with no blinking while changing tracks).

Furthermore, I don’t like random music shuffling, but I like to have the choice, so I take your random function as a commentary - so everybody can decide to use it or not.

You are right here

adcockm
said you can go up to 380000 with a Pico 2 - and he is right.

My new Code with

'music
x=1
y=0
tmp$=""
Dim mp3$(100)
path$ = "b:\music\"


f1=1
f$=Dir$(path$ + "*.mp3",FILE)
cover$ = "cover.bmp"

Do While f$<>""
   mp3$(f1)=path$+f$
   f$=Dir$()
   f1=f1+1
Loop


'Randomize
'For i=1 To f1 - 1
'   k$ = mp3$(i)
'   j = Rnd(f1 - 1) + 1
'   mp3$(i) = mp3$(j)
'   mp3$(j) = k$
'Next


CLS
On error skip 1
Load image(path$ + cover$)
Print "########################"
Print "####### SiD Music ######"
Print "########################"
Do While x < f1
  Print @(0,40) mp3$(x)
  Open mp3$(x) For input As #1
  y = Lof(1)
  Close #1
  Play mp3 mp3$(x)
  z=Cint(((y*8)/320000))

  Do While z > 0
     k$ = Inkey$

    If k$ <> "" Then
      Select Case Asc(k$)
        Case 131: Play stop
                  z=0
        Case 130: Play stop
                  x = x-2
                  z=0
        Case 32: Play stop
                        CLS
	                x=f1
                        z=0
      End Select
    End If

    Pause 100
    z=z-1
    min = Int(z / 60)
    sec = z Mod 60
    If sec < 10 Then
      tmp$ = Str$(min)+":0"+Str$(sec)+"  "
    Else
      tmp$ = Str$(min)+":"+Str$(sec)+"   "
    EndIf
    Print @(0,60) tmp$
    Pause (900)
   Loop
  Play stop
  x=x+1
Loop
2 Likes