// Name: Select and Play Audio File // Description: Select an audio file from your system and play it // Author: johnlindquist import "@johnlindquist/kit" let audioFile = await selectFile("Select an audio file to play") if (!audioFile) { await div(md("No file selected")) exit() } // Check if the selected file is an audio file const audioExtensions = ['.mp3', '.wav', '.m4a', '.aac', '.ogg', '.flac', '.wma'] const fileExtension = path.extname(audioFile).toLowerCase() if (!audioExtensions.includes(fileExtension)) { await div(md(`**${path.basename(audioFile)}** is not a supported audio file format. Supported formats: ${audioExtensions.join(', ')}`)) exit() } await div(md(`Playing: **${path.basename(audioFile)}**`)) try { await playAudioFile(audioFile) await div(md(`✅ Finished playing: **${path.basename(audioFile)}**`)) } catch (error) { await div(md(`❌ Error playing audio file: ${error.message}`)) }