- Project: Audio playback app that let user search and play a song.
- View live: Twitch Frontend Music Player
- Languages: JavaScript, TypeScript
- Frontend: React
- Frameworks and Libraries: Material-UI
- API: Spotify
- Install packages
npm install
- Create .env file, you can reference to
.env.example
REACT_APP_SPOTIFY_CLIENT=<Your Spotify client ID here>
REACT_APP_SPOTIFY_SECRET=<Your Spotify Client Secret here>
- Start server
npm start
-
API
- POST request to get Spotify token
{ "access_token": "", "token_type": "Bearer", "expires_in": 3600 }
- GET request to fetch songs based on query string
{ "tracks": { "items": [ { "albums": {}, "artists": {}, . . . } ] } }
- POST request to get Spotify token
-
Responsive View
-
User Flow
- Type song name into search box, hit 'Enter'
User will see a list of songs - Hover over song card, users will see a play button
- Click on a song, song will start playing
- Control play/paused state, volumes and progress of a song with footer music player controls
- Type song name into search box, hit 'Enter'
-
Distinct design decisions
- Use useContext and useReducer to manage states
- Use OuterController to import Global Context values and use
React.memo
on InnerController to avoid excessive component rerendering
-
Use a modern JS Library/Framework
- React
-
Three different user interactions
- Search a song
- Click song to play
- Toggle play pause
- Change progress bar to fast forward or rewind
- Change volume
-
A specified architectural pattern
- MVC
-
3rd Party Restful API
-
5 UI components from Material-UI core
- Grid
- AppBar
- InputBase
- Paper
- CardMedia
- Typography
- Popover
- Slider
-
Reusable UI
- Song Component