Playing an MP3 file

by Richard Russell, May 2015

This is a very simple, no-frills, way of playing an MP3 music file:

        mp3file% = OPENIN("*.mp3")
        IF mp3file% = 0 THEN QUIT
        CLOSE #mp3file%
        mp3file$ = $$!420
 
        PROCmci("open """ + mp3file$ + """ type mpegvideo alias music")
        PROCmci("play music")
        END
 
        DEF PROCmci(cmd$)
        LOCAL R%, S%
        DIM R% LOCAL 128
        SYS "mciSendString", cmd$, R%, 128, 0 TO S%
        IF S% ERROR 100, "mciSendString failed: " + STR$(S%)
        ENDPROC

If you want the MP3 file to be played repeatedly you can change the play command to:

        PROCmci("play music repeat")