Skip to content

Instantly share code, notes, and snippets.

Last active Mar 19, 2020
What would you like to do?
#!/usr/bin/env bb
(require '[ :refer [sh]])
(defn exit [error]
(println error)
(System/exit 1))
(defn open-folder [folder]
(let [folder (some-> folder (io/file))]
(when (nil? folder)
(exit "usage: shufle-play.clj <music folder>"))
(when-not (.exists folder)
(exit (str "music folder not found:" (.getName folder))))
(defn play-mp3s
(play-mp3s (shuffle mp3s) []))
([[mp3 & more] played]
(if mp3
(println "playing" (.getName mp3))
(sh "ffplay" "-nodisp" "-autoexit" (.getAbsolutePath mp3))
(recur more (conj played mp3)))
(recur (shuffle played) []))))
(->> (first *command-line-args*)
(filter #(.endsWith (.getName %) ".mp3"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment