Console-based music player that supports:
- Add, display, edit, delete songs
- Shuffle playlist
- Play / Pause / Resume / Next / Prev / Stop
- SDL2
- SDL2_mixer (built with support for your audio formats, e.g., MP3/OGG/WAV)
- A C compiler (GCC/Clang or MinGW)
gcc -o music_player src/music_player.c -lSDL2 -lSDL2_mixerIf SDL is installed in a non-standard path, add -I and -L flags accordingly.
gcc -o music_player.exe src\music_player.c -lmingw32 -lSDL2main -lSDL2 -lSDL2_mixerEnsure SDL2 and SDL2_mixer DLLs are in the same folder as the executable or on PATH.
./music_player # or music_player.exe
Program shows a numbered menu:
- Add Song — enter Title, Artist, and file path to an audio file (e.g., C:\music\song.mp3)
- Display Songs — prints the playlist (index, title, artist)
- Edit Song — choose index; enter new title/artist or press Enter to skip
- Shuffle Playlist — randomizes the order
- Player — interactive sub-menu:
- 1 Play: loads current index and starts playback
- 2 Pause
- 3 Resume
- 4 Next: move to next index and play
- 5 Prev: move to previous index and play
- 6 Shuffle: randomize playlist, reset current index
- 7 Stop: stop playback
- 8 Back: return to main menu
- Delete Song — remove by index
- Exit
Expected Input: integers for menu choices and text for song info.
Expected Output: status lines like "Playing:", "Paused.", "Song deleted.", or any SDL error messages if loading fails.
- Current shuffle is a simple swap-based approach. For unbiased results, prefer Fisher–Yates:
for (int i = n - 1; i > 0; --i) { int j = rand() % (i + 1); swapSongs(i, j); }
- Always free Mix_Music before loading a new one to avoid leaks (handled in code).
- Validate file paths exist before attempting to load (can be added with
fopencheck).
Group 62 — Music Player Project (Mentor: Sangeeta)