Play random mp3 in folder
Play random mp3 in folder
hey, i want to make a musicplayer, and i don't know how to play random mp3 files in a folder successively with SoundPlay.
Re: Play random mp3 in folder
If you put all your songpaths into an array; https://biga-ahk.github.io/biga.ahk/#/?id=sample can choose a random one
Code: Select all
A := new biga() ; requires https://www.npmjs.com/package/biga.ahk
; put all songs into an array
array := []
Loop, Files, % "C:/music/*.mp3"
{
array.push(A_LoopFilePath)
}
; choose one file to play
file := A.sample(array)
SoundPlay, % file
return
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: Play random mp3 in folder
try:
Code: Select all
path := "C:\Users\" A_UserName "\Music"
loop, files, %path%\*.mp3
lst .= A_LoopFileFullPath "`n"
sort, lst, Random
for x,y in strsplit(lst,"`n")
soundplay, %y%, wait
14.3 & 1.3.7
Re: Play random mp3 in folder
Thank you, this is working!!!