Skip to content
kluvinPublic

About

a nice game to play alone when you forget which songs are in your playlist

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Pling

A real-time music buzzer game for the living room. One phone is the host and plays the songs in Spotify; everyone else's phone is a buzzer. First to hit PLING answers, and the host judges.

It started as a tech demo for building real-time games quickly. This version runs on Cloudflare: one Durable Object per room via PartyServer, and a React app served as static assets from the same Worker.

How a game works

  1. The host creates a room (Red vs Blue, or free-for-all) and shares the code or QR code.
  2. The host taps Play in Spotify: the song opens in the host's own Spotify app (connect that phone to a speaker) and the round timer starts.
  3. Players buzz from their phones. In Red vs Blue, one phone can be a shared buzzer with a button per team.
  4. The host pauses the music and marks the answer right or wrong. A wrong answer locks that team (or player) out for the rest of the song.

Music: the host picks a built-in deck, imports a list, starts a Blend, shares a Spotify Blend, collaborative playlist or Jam, or chooses Own music and plays anything from any app.

Blend: every player can add their own playlist from their phone (Music at the top). The host mixes them: songs that are on several lists come first, then an equal share from each list, however long it is. Optionally keep only the songs you have in common. When a song is revealed, it shows whose list it came from. Nobody sees what others added until it's played.

Spotify Blend, collaborative playlist or Jam: let Spotify collect the music. The host makes one in Spotify, copies its share link and pastes it under Music → Spotify. Players get a button (Join the Spotify Blend, Add songs to the playlist or Join the Jam) that opens it in their own Spotify app. The host plays it on shuffle, skips to the next song and starts each round; Pling does the buzzers and scores. Pling can't see these songs, so there's no reveal card. Only links on Spotify's own domains (open.spotify.com, spotify.link) are accepted.

  • Spotify Blend: mixes the taste of up to 10 people into one playlist.
  • Collaborative playlist: everyone adds songs from their phone.
  • Spotify Jam: a shared live queue for up to 32 people. Only the host needs Premium.

Getting a playlist in (for a blend or as the deck):

  • Spotify on a computer: open the playlist, select all songs (Ctrl/⌘+A), copy (Ctrl/⌘+C) and paste into Pling. You get one link per song. Spotify only copies links, so these songs show their name once opened in Spotify.
  • A CSV file, for example from a playlist export tool like Exportify, or any sheet with artist and title columns.
  • Your Spotify data export (Playlist1.json, YourLibrary.json).
  • Typing or pasting "Artist - Title" lines.

Spotify and compliance

Pling does not use Spotify's Web API, SDKs or embedded player. It only shows plain open.spotify.com links that the host taps, so playback happens in the host's own Spotify app on their own account. Song lists come from the built-in decks or from what players paste or import from files they already have. There is deliberately no "log in with Spotify": that would use Spotify's Web API, whose developer terms don't allow games or quizzes. Starter decks only store artist and title, so their links open a Spotify search; pasted or imported tracks link straight to the song. Pling is not affiliated with Spotify.

Code layout

Path What it is
src/shared/game.ts All game rules as pure functions (no I/O, time passed in).
src/shared/view.ts What each client is sent; players never see the song until it's revealed.
src/shared/spotify.ts Spotify links, and reading pasted lists, CSV files and data exports.
src/shared/blend.ts The blend: matching songs across lists and picking a fair cross-section.
src/shared/decks.ts Built-in starter decks.
src/server/index.ts The Worker and the Room Durable Object.
src/client/ The React app.
messages/en.json, messages/nb.json UI text in English and Norwegian (Bokmål), compiled by Paraglide.
cloudflare.config.ts Worker, static assets and the Room Durable Object, for the cf CLI.
test/ Unit tests (Vitest).

The room server follows one loop: apply the change with the pure rules, save the state to Durable Object storage, set a single alarm for the next thing that has to happen (round timeout, host handover, deleting an empty room), and send each connection its view. Rooms hibernate when idle, so quiet rooms cost nothing.

Development

npm install        # also generates Worker types in .cloudflare/types (cf workers types)
npm run dev        # cf dev: Vite + the real Workers runtime, with hot reload
npm test           # unit tests
npm run typecheck
npm run preview    # build, then run the production build locally

Languages

The UI is in English and Norwegian (Bokmål), using Paraglide. A saved choice wins, then the browser's language (nb, nn and no all get Norwegian), then English. Players switch under Settings → Language or on the home page.

To change or add text, edit messages/en.json and messages/nb.json (same keys in both) and use it as m.key() from src/client/i18n.ts. npm run i18n compiles the messages to src/paraglide/ (also done by npm install, dev and build). The message-format plugin is loaded from node_modules, not a CDN, so builds work offline. The server sends errors in English; the client translates the ones it knows (translateServerError).

Deploying to Cloudflare

Pling uses Cloudflare's cf CLI (installed as a dev dependency), not Wrangler.

Run it once by hand:

npx cf auth login
npm run deploy

cf deploy builds, uploads and prints the *.workers.dev URL. Durable Objects with SQLite storage are available on the Workers Free plan.

For automatic deploys on every push to main, add two repository secrets in GitHub (Settings → Secrets and variables → Actions):

  • CLOUDFLARE_ACCOUNT_ID: shown in the Cloudflare dashboard sidebar.
  • CLOUDFLARE_API_TOKEN: create one from the Edit Cloudflare Workers template.

History

The first version was a Phoenix LiveView app on Fly.io using the Spotify embed player and a separate playlist-fetcher service. It's in the git history before the move to Cloudflare.

About

a nice game to play alone when you forget which songs are in your playlist

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages