EltionBehrami / Cherry-Music

Welcome to our music streaming haven! Dive into a seamless audio experience with our platform, offering users the joy of listening to music and curating personalized playlists effortlessly. 🎵 🍒
https://cherry-music.onrender.com/
0 stars 0 forks source link

Cherry Music

Cherry Music is a clone of Apple Music, providing a seamless music streaming experience. Key features include albums, playlists, a dynamic playbar, and a search functionality.

Cherry Music

Cherry Music Splash

Technologies Used

React Redux CSS3 Ruby Rails Postgres AWS Render

Key Features

Music Player Controls

The following JavaScript code provides functions for controlling a music player in a React application:

These functions are commonly used in a music player application to manage the playback flow and user interaction.

const next = () => {
    if (currentSongIndex < queue.length - 1) {
        setCurrentSongIndex(currentSongIndex + 1);
    }
}

const previous = () => {
    if (currentSongIndex > 0) {
        setCurrentSongIndex(currentSongIndex - 1);
    }
}

const play = () => {
    if (currentSong) {
        audioRef.current.currentTime = audioRef.current.currentTime || 0;
        dispatch(playSong());
    }
};

const pause = () => {
    dispatch(pauseSong());
}

Creating Playlists

Users can personalize their music experience by creating and managing playlists. The implementation includes CRUD operations for playlists, ensuring a tailored and consistent playlist experience across devices.

This code snippet is part of a Redux reducer handling actions related to adding or removing songs from playlists in a music app.

case ADD_SONG_TO_PLAYLIST: 
        const { playlistId, songId } = action.payload;
        const playlistToUpdate = newState[playlistId];
        if (playlistToUpdate) {
            const updatedPlaylist = {
                ...playlistToUpdate,
                playlistSongs: [...playlistToUpdate.playlistSongs, songId],
            };
            return {
                ...newState,
                [playlistId]: updatedPlaylist,
            };
        }
        return newState;
case REMOVE_SONG_FROM_PLAYLIST: 
        const playlist = {...newState[action.payload.playlistId]}

        playlist.playlistSongs = playlist.playlistSongs.filter((id) => id !== action.payload.songId)
        playlist.playlistSongIds = playlist.playlistSongIds.filter((id) => id !== action.payload.playlistSongId)

        const updatedState =  {
            ...newState, [action.payload.playlistId]: playlist,
        };

        return updatedState;

To add a song to a playlist:

To delete a song from a playlist:

Conclusion

Cherry Music delivers a feature-rich music streaming experience, combining the elegance of Apple Music with the flexibility of a custom-built solution. The use of React, Redux, Ruby on Rails, PostgreSQL, and AWS showcases a harmonious synergy between frontend, backend, database, and cloud technologies, providing users with a seamless and enjoyable music platform.

Features in Development:

We appreciate your support and look forward to bringing you more exciting updates. Stay tuned for an even more dynamic and feature-rich Cherry Music experience!