Appearance
Playback on one device and preemption
Who: listener (entitled or not); system for ingest and aggregation.
Entry points
| Kind | Entry |
|---|---|
| REST | POST /playback/lease, POST /playback/lease/heartbeat, POST /playback/lease/release, GET /playback/manifest, GET /playback/keys/:keyId, POST /playback/events |
| REST (queue) | GET/PUT/PATCH /me/playback/queue, POST /me/playback/queue/items, DELETE /me/playback/queue/items/:itemId, POST /me/playback/queue/advance, POST /playback/automix/plan |
| REST (history) | GET /me/recently-played, GET/PUT /me/resume-positions, GET /me/continue-listening |
Socket /playback | lease:claim, lease:heartbeat, lease:release, events:ingest; server → playback:preempted, queue:updated |
| Deep link | track, release, video, episode, djSet |
Flow
- Claim:
lease:claim { deviceId }(orPOST /playback/lease) →{ fencingToken, heartbeatSeconds, expiresInSeconds }. Claiming bumps the fencing token. - Manifest:
GET /playback/manifest?contentType&contentId&deviceId&fencingToken[&lossless]. Entitled (canPlayFull) →rendition: "full"; else preview (reason: not_entitled).losslessonly on plans with it. - Key:
GET /playback/keys/:keyId?deviceId&fencingToken, gated by entitlement and lease. - Heartbeat every
heartbeatSeconds(lease:heartbeat). The lease lapses afterexpiresInSeconds. - Events:
events:ingest/POST /playback/events(start,progressevery 10 s,pause,seek,skip,complete,end,error,offline_play…). Queued onplayback.ingest; filed into monthlyplay_eventspartitions. - Qualified stream after
min(30 s, duration / 3)of a full rendition, recorded with the listener's plan state → eventplayback.stream.qualified→ recommendation signals, creative streaks/wrapped, studio milestones. - Nightly:
playback.aggregate-daily(per recording, creator, country, source),playback.fraud-scan(loops, short repeats, device farms),playback.maintenance(partitions). - Queue: server-side queue with shuffle, repeat, crossfade and automix (
POST /playback/automix/planuses media analysis). Changes emitqueue:updated { version }.
Preemption
- Device B claims → fencing token +1 →
playback:preempted { deviceId, fencingToken, claimedByDeviceId, currentFencingToken }touser:<id>. - Device A pauses at once. Its next heartbeat, manifest or key call answers
PLAYBACK_LEASE_STALE. - A can take the lease back with
lease:claim(preempting B), which is the "Play here" button.
Exit states
| State | Code | Actions | Client next |
|---|---|---|---|
| Playing full | — | — | Heartbeat, send events |
| Another device took over | PLAYBACK_LEASE_STALE | retry | Show "Playing on (device name)", offer claim |
| No lease sent | PLAYBACK_LEASE_REQUIRED | retry | Claim, then retry |
| Not entitled to full | PLAYBACK_NOT_ENTITLED | start_trial, subscribe | Preview + upsell |
| Gone | PLAYBACK_CONTENT_NOT_FOUND | — | Skip to next |
| Device unknown | DEVICE_NOT_FOUND | — | Re-register device (sign in) |
| Queue too long | PLAYBACK_QUEUE_TOO_LONG | — | Trim to 500 |
| Bad events | PLAYBACK_EVENT_INVALID | — | Drop the batch |
Client next
On reconnect refetch GET /me/playback/queue (compare version) and re-claim only if the person presses play.
Notifications
None directly. Feeds engagement.continue_listening when engagement is wired (I6).
Known gaps
- Studio retention curves are empty: playback keeps no per-position listening curve (I14).