Action | Type | Resolved On |
|---|---|---|
| Shuffle the playlist without replacement, and let the previous track come from the play history | feature | - - - |
project bearlabs·type feature
The shared listening playlist had neither: it only walked the list forward, one track after the other, and offered no way back. The technique is taken from the two paid players we studied — the CodeCanyon "Progression Player" (a shuffle that does not put a track back until every other one has played) and the "Focus Audio Player" (a previous that walks the play history rather than up the list, and a shuffle that is drawn again when the cycle runs out). Three rules travel with the technique and all three matter: the order is DRAWN ONCE and kept, so the list under the person does not reshuffle itself while they look at it; the previous track comes from the HISTORY — the song that actually played before this one, which under a shuffle is a different track from the one above it in the list; and turning the shuffle on does NOT interrupt the track that is playing, it draws the new order around it. Two traps: `sort(() => Math.random() - 0.5)` is a biased shuffle — not a valid comparator, so the tracks at the ends of the list come up more often than the ones in the middle — and a new cycle must not start with the track that just finished, or the shuffle sounds broken even though it obeys the rule. Landed in the shared module as components/listening/lib/queue.ts, pure data and pure moves so the rules can be tested without a browser, wired into playlist.tsx with a 随机 toggle and 上一首 / 下一首 buttons; the shuffle is a setting and is remembered, the same way the watching side remembers the speed.