Skip to content

NikhByte/Group62_MusicPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Group 62 — C Music Player (SDL2 + SDL_mixer)

Overview

Console-based music player that supports:

  • Add, display, edit, delete songs
  • Shuffle playlist
  • Play / Pause / Resume / Next / Prev / Stop

Requirements

  • SDL2
  • SDL2_mixer (built with support for your audio formats, e.g., MP3/OGG/WAV)
  • A C compiler (GCC/Clang or MinGW)

Build (Linux/Mac)

gcc -o music_player src/music_player.c -lSDL2 -lSDL2_mixer

If SDL is installed in a non-standard path, add -I and -L flags accordingly.

Build (Windows / MinGW)

gcc -o music_player.exe src\music_player.c -lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer

Ensure SDL2 and SDL2_mixer DLLs are in the same folder as the executable or on PATH.

Run

./music_player   # or music_player.exe

Usage / Expected I/O

Program shows a numbered menu:

  1. Add Song — enter Title, Artist, and file path to an audio file (e.g., C:\music\song.mp3)
  2. Display Songs — prints the playlist (index, title, artist)
  3. Edit Song — choose index; enter new title/artist or press Enter to skip
  4. Shuffle Playlist — randomizes the order
  5. 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
  6. Delete Song — remove by index
  7. 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.

Notes & Optimizations

  • 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 fopen check).

Credits

Group 62 — Music Player Project (Mentor: Sangeeta)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages