MusicBox is a command-line music player developed in Java. It allows users to play WAV audio files with functionalities such as play, pause, resume, and stop, alongside playlist navigation and playback progress tracking. This project demonstrates the integration of basic and intermediate Java concepts with audio processing libraries.
-
Audio Playback
- Play WAV files directly from a specified directory.
- Support for loading new files during runtime.
-
Playback Controls
- Play: Start playing an audio file.
- Pause: Pause playback and save the current position.
- Resume: Resume playback from the last paused position.
- Stop: Stop playback and reset the position to the beginning.
-
Playlists
- Automatically play the next track in a playlist.
- Display a message when the playlist ends.
-
Real-Time Feedback
- Console messages to indicate actions such as "Music finished playing!" or "Playback paused."
- Java Development Kit (JDK) 8 or later.
- A terminal or command-line environment.
-
Clone the repository:
git clone https://github.com/your-username/musicbox.git cd musicbox -
Compile the code:
javac -d bin src/entities/MusicPlayer.java src/Main.java
-
Run the program:
java -cp bin Main
-
Follow the prompts to interact with the music player:
- Enter the file path of a WAV file.
- Use the commands
play,pause,resume, andstopas instructed.
MusicBox
├── src
│ ├── entities
│ │ └── MusicPlayer.java # Core logic of the music player.
│ ├── Main.java # Command-line interaction logic.
├── resources # Sample WAV files.
├── README.md # This document.
└── LICENSE # Project license.
- javax.sound.sampled: For audio file processing.
- Java Collections: For playlist management.
- Command-Line Input: For user interaction.
- File and audio handling in Java.
- Building interactive command-line programs.
- Using event listeners for managing audio streams.
- Structuring modular Java projects.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/new-feature). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature/new-feature). - Open a Pull Request.
Thanks for exploring this project! If you found it helpful, give it a ⭐ and share it with fellow Java enthusiasts. 🎉