Colorflow Player is a Node.js music streaming app (Spotify and Deezer) where the color of the album view and now playing screen changes to match the predominate color of the album artwork which is called ColorFlow.
See the open Issues for planned updates for v2 of the web app.
Colorflow was first introduced in iTunes and the iOS Music app but was removed in iTunes 12.5 and iOS 10. Since then a number of jailbreak tweaks (the most popular being ColorFlow) have been released and a few third-party iOS Music apps such as Doppler and Power Player have supported the feature.
Chris Banes created an Android utility using Java to take the three dominant colours (primary, secondary and tertiary) from an image and create two colours (primary text and secondary text) that provide enough contrast from the background so text is readable. His approach uses ColorThief as a basis and then uses a custom approach to fine tune the results.
server.js
is the main server file for the web app which runs the server and sets up live reloading for server and client code (if process.env.NODE_ENV
is development). It also includes Express, Express Session and sets Mongo as Session Storage as well as includes the routes stored in the routes
directory and 404 route.public/css
. Split into main.css
, responsive.css
, spotify.css
and deezer.css
so the main styles are in main.css
with some mobile responsive tweaks in responsive.css
. The Spotify and Deezer routes have their own CSS for their branded UI which contains the necessary media queries at the bottom of the file. Comments have been used to divide each file into sections.public/css/fonts
and the rest are Google Fonts.public/js/script.js
. The main JS function handles audio playback since the play icon is a Font Awesome icon and dynamically changes the text color so it's readable if the dynamic background color is light or dark. It also communicates with the server's /analytics
route to trigger analytics updates.Express - Node.js Web Server
Express Session - Creates session to track analytics and save user logins
connect-mongo - Use MongoDB Database as permanent session storage so analytics can be retrieved from all sessions
EJS - Templating Language
PassportJS - Passport allows to easily authenticate users via a variety of strategies
Passport-Local - Passport Local Strategy to authenticate users via username and password to view analytics
bcrypt - Salts and hashes user passwords before they are stored in the database
Spotify Web API Node - Node.js Spotify API Wrapper
Deezer Public API - Node.js Deezer Public API Wrapper (Parts of the Deezer API where users don't need to log in)
Color Thief Node - Analyses colours from album artwork, playlist artwork and artist images to generate background color
dotenv - Securely store environment variables such as API keys and DB details
fs - Used to download artwork images to the server filesystem so Color Thief can analyse them. The downloaded artwork/images are then used on the album/artist/playlist pages to avoid waiting for them remotely. Stored in public/img/analysed-artwork
. Images are separated by streaming service and then by type. Fallbacks are provided in public/img/fallback-imgs
if there is no image available.
MongoDB - Node.js driver to interact with MongoDB Database. The database is used as a permanent session store and for users (usernames and hashed passwords.)
node-fetch - Node.js version of Fetch to download artwork from remote URLs
npm start
runs the web app and npm run server
starts the live-reload development server using the below NPM modules.