How to make a loop
Posted: Wed Dec 27, 2023 9:39 pm
Here are my code for mp3 player. I have figure out how too start, pause, resume and stop the mp3 file. But how do make a loop. After file stop, cant make it to play again, without start the program again.
@VERSION 10,0
@APPTITLE "ROD-DEMO-PLAYER"
@APPVERSION "$VER: ROD-DEMO V0.0.1 (2023.12.27)"
@APPCOPYRIGHT "(C) Copyright 1971-2071 by Magnus Hammarström"
@APPAUTHOR "Magnus Hammarström"
@REQUIRE "avcodec", {Link = True}
@DISPLAY {X=1645, Y=5, Borderless = True, DragRegion = {{X=0, Y=0, Width=350, Height=610}}}
@BGPIC 1, "BG.png", {LoadAlpha = True}
@MUSIC 1, "Media/retro.mp3"
WaitKeyDown("Return")
PlayMusic(1)
WaitKeyDown("p")
PauseMusic(1)
WaitKeyDown("ENTER")
ResumeMusic(1)
WaitKeyDown("END")
StopMusic(1)
/**************************/
/*** Keyboard Function ***/
/**************************/
Function
p_EventFunc(msg)
Switch(msg.action)
Case "OnKeyDown":
/*****************/
/* Enter key ESC */
/* Exit program */
/*****************/
If msg.key="ESC"
End()
EndIf
EndSwitch
EndFunction
InstallEventHandler({OnKeyDown = p_EventFunc})
EscapeQuit(True)
Repeat
WaitEvent
Forever