Search code examples
loadingqb64

Loading bar or percentage possible while loading audio file in qb64


this is what i currently have

    PRINT "Loading..." 
soundHandle& = _SNDOPEN("Music.mp3") 'opens the sound file
_SNDPLAYFILE "Music.mp3", , .25 'plays the sound file

what I want it to do is a percentage to go up while it loads, if possible,


Solution

  • Since I don't know the size of the file to be loaded, all I can offer is this:

    REM sample to display approx. percent while loading file
    CLS
    PRINT "Loading..."
    PRINT "000%";
    ON TIMER(1) GOSUB DisplayPercent
    TIMER ON
    soundHandle& = _SNDOPEN("Music.mp3") 'opens the sound file
    _SNDPLAYFILE "Music.mp3", , .25 'plays the sound file
    DO WHILE INKEY$="":LOOP 'wait while sound plays
    TIMER OFF 'turn off timer after entire file played
    END
    DisplayPercent:
    P = P + 10
    IF P <= 100 THEN
        FOR L = 1 TO 4
            PRINT CHR$(29); " "; CHR$(29);
        NEXT
        PRINT RIGHT$("000" + MID$(STR$(P), 2), 3); "%";
    END IF
    RETURN