A lightweight, interactive command-line audio player built using Java's native javax.sound.sampled API. This project demonstrates how to load, play, and control audio files directly from the terminal without needing any external graphical interface.
Thanks to Java's built-in audio system, this program natively supports the following uncompressed audio formats:
- .wav (WAVE format)
- .au (Sun/NeXT audio format)
- .aiff (Audio Interchange File Format)
(Note: Compressed formats like .mp3 or .ogg are not natively supported by standard Java libraries).
Before running the code, you must provide the local path to your audio file inside the code.
- Open
Main.java. - Locate the following line in the
mainmethod:String filePath = ""; //COPY THE FILE PATH HERE - Paste the absolute path to your
.wav,.au, or.aifffile between the quotation marks.- Windows Example:
"C:\\Users\\YourName\\Desktop\\song.wav"(Remember to use double backslashes) - Mac/Linux Example:
"/Users/YourName/Desktop/song.wav"
- Windows Example:
Once the program is running, enter the following single-character commands in your terminal:
- P -> Play the audio
- S -> Stop / Pause the playback
- R -> Reset / Rewind the audio back to the beginning
- Q -> Quit the application