isFile()) { $ext = strtolower(pathinfo($file->getFilename(), PATHINFO_EXTENSION)); if (in_array($ext, $allowed, true)) { // Build a web path $absPath = $file->getPathname(); $relPath = str_replace('\\','/', substr($absPath, strlen(__DIR__) + 1)); // songs/... // Basic title from filename (without extension) $title = preg_replace('/[_\-]+/',' ', pathinfo($file->getFilename(), PATHINFO_FILENAME)); $title = trim($title); $songs[] = [ 'title' => $title, 'url' => $relPath, 'name' => basename($relPath), 'ext' => $ext, 'size' => filesize($absPath), ]; } } } } // Sort alphabetically by title usort($songs, fn($a,$b) => strcasecmp($a['title'], $b['title'])); ?> Music Player – songs/

Music Player

Folder: /songs • Files found:
Click a track to play • ⏭️ Next: N • ⏮️ Prev: P • ␣ Space: Play/Pause
No audio files found. Add files to /songs (mp3, m4a, aac, ogg, wav, flac, opus, webm).