Music Room is a collaborative music application that allows users to create and join rooms where they can collaboratively play and control music using Spotify. The application leverages Spotify's API to manage music playback and implements a voting system for skipping tracks, ensuring a democratic and engaging listening experience.
- Create a room with a unique room code.
- Join a room using a room code.
- Vote to skip the current song.
- Control music playback (play, pause, skip).
- Authenticate with Spotify.
Room Creation: The host creates a room by sending a POST request to the /createroom
endpoint. This generates a unique room code that can be shared with other users. The room details are stored in the database, and the room code is used to identify the room in subsequent operations.
Joining a Room: Users can join a room using the unique room code by sending a POST request to the /join-room
endpoint. This adds the user to the room, allowing them to participate in music playback control and voting.
Leaving a Room: Users can leave a room by sending a POST request to the /leave-room
endpoint. This removes the user from the room and updates the room's participant list.
Updating Room Settings: The host can update room settings (such as the number of votes required to skip a song) by sending a PATCH request to the /update-room
endpoint.
Playing and Pausing Songs: Users can play and pause songs in the room by sending PUT requests to the /play-song
and /pause-song
endpoints, respectively. These actions are controlled through Spotify's API.
Skipping Songs: To skip a song, users vote by sending a POST request to the /skip-song
endpoint. The song is skipped only if the number of votes meets the threshold defined by the room settings.
Authentication: Users authenticate with Spotify by first getting the Spotify authentication URL through the /get-auth-url
endpoint. After the user authenticates, Spotify redirects them to a specified redirect URI, which is handled by the /redirect
endpoint. The /is-authenticated
endpoint checks if the user is authenticated.
Current Song Information: The /current-song
endpoint retrieves the currently playing song's details using Spotify's API.
-
Create Room
- Endpoint:
/createroom
- Method: POST
- Description: Creates a new room with a unique room code.
- Endpoint:
-
Get Room
- Endpoint:
/get-room
- Method: GET
- Description: Retrieves details of a room by room code.
- Endpoint:
-
Join Room
- Endpoint:
/join-room
- Method: POST
- Description: Allows a user to join a room using a room code.
- Endpoint:
-
User in Room
- Endpoint:
/user-in-room
- Method: GET
- Description: Checks if a user is in a room.
- Endpoint:
-
Leave Room
- Endpoint:
/leave-room
- Method: POST
- Description: Allows a user to leave a room.
- Endpoint:
-
Update Room
- Endpoint:
/update-room
- Method: PATCH
- Description: Updates room settings.
- Endpoint:
-
Get Auth URL
- Endpoint:
/get-auth-url
- Method: GET
- Description: Retrieves the Spotify authentication URL.
- Endpoint:
-
Redirect URI
- Endpoint:
/redirect
- Method: GET
- Description: Handles Spotify's authentication callback.
- Endpoint:
-
Check Authentication
- Endpoint:
/is-authenticated
- Method: GET
- Description: Checks if the user is authenticated with Spotify.
- Endpoint:
-
Current Song
- Endpoint:
/current-song
- Method: GET
- Description: Retrieves the currently playing song.
- Endpoint:
-
Pause Song
- Endpoint:
/pause-song
- Method: PUT
- Description: Pauses the current song.
- Endpoint:
-
Play Song
- Endpoint:
/play-song
- Method: PUT
- Description: Plays the current song.
- Endpoint:
-
Skip Song
- Endpoint:
/skip-song
- Method: POST
- Description: Votes to skip the current song. Requires a certain number of votes to skip.
- Endpoint:
- Python 3.10+
- Django 3.2+
- Spotify Developer Account
-
Clone the repository:
git clone https://github.com/Edwin574/Music-Room.git cd music-room
-
Create a virtual environment and activate it:
Make sure you have pipenv
installed you can use sh pip install pipenv
sh pipenv shell
-
Install the required dependencies:
pipenv install
-
Set up environment variables: Create a
.env
file in the project root and add your Spotify API credentials:SPOTIFY_CLIENT_ID=your_spotify_client_id SPOTIFY_CLIENT_SECRET=your_spotify_client_secret SPOTIFY_REDIRECT_URI=your_spotify_redirect_uri
-
Apply database migrations:
python manage.py migrate
-
Run the server:
python manage.py runserver
An Easy way of holding an intresting music jam by allowing anyone in a house party to control music.
- Create Room:
curl -X POST http://127.0.0.1:8000/createroom