diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fa3ba4..1659b5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,38 @@ # Changelog +## Sin publicar — El reproductor completo, y lo que sigue después + +Tocar la barra del reproductor **abre el reproductor completo**, como el de Spotify: la portada en +grande, el título del episodio entero en vez de recortado, el programa, el autor, el número de +episodio y la fecha, una **barra que se arrastra** (el slider de la casa, con `data-nodrag` para que +un arrastre lateral no se lea como cerrar la hoja), el tiempo transcurrido y **lo que falta** —que es +el número con el que se decide si da para otro episodio—, −15 / +30, anterior y siguiente, y +**"Después: …"** con el nombre del que sigue. Es una *hoja*, no una ruta: una pantalla dentro del +router se desmonta al navegar, y esto no puede ser nunca lo que corte el audio. Se cierra +deslizando hacia abajo, con el gesto de siempre, o con el botón de atrás de Android. + +Para una **emisora** el mismo reproductor muestra el logo, el nombre, el género y qué está sonando +—o que esa emisora no publica lo que suena— y **no dibuja barra de progreso**: una radio en vivo no +tiene posición ni final, y decirlo es mejor que un slider muerto. + +**Cuando un episodio termina, sigue el siguiente** de la lista en la que lo pusiste a sonar, sin +tocar el teléfono; al final de esa lista se detiene y el reproductor completo lo avisa antes +("Es el último episodio de esta lista"). El que terminó queda marcado como escuchado antes de pasar +al otro. Lo mismo está en la **pantalla bloqueada**: los botones de siguiente y anterior ahora +llegan al elemento de audio, que es donde alguien con las manos en la barra los va a apretar. + +Dos cosas que aparecieron revisando esto, y que valen más que la función: + +- `setRadioNow` llamaba a una función que ya no existía desde que el reproductor se unificó + (`setMediaSession`, hoy `setStreamSession`). El error quedaba **tragado** por el `.catch` del + sondeo: la pantalla mostraba el tema —el estado se actualizaba antes de la línea que fallaba— y la + **pantalla bloqueada nunca se enteraba**. Un fallo invisible que sólo se ve comparando lo que dice + el teléfono con lo que dice la app; ahora hay un test que lo mira, y se comprobó por mutación. +- `useUI` tenía **dos definiciones** de `setRadioVolume` y `setRadioNow`: al insertar el bloque de + podcasts quedó el final del bloque de radio duplicado, y en un objeto literal la última gana en + silencio. Una de las dos copias era código muerto que se leía como vivo — y fue justamente la que + hizo que el primer intento de comprobar lo anterior "pasara". + ## Sin publicar — Música se ordena: pestañas, buscador y listas de diez La pantalla de Música era una sola columna: la radio, después los podcasts, después las listas. diff --git a/README.md b/README.md index 5ef51e9..c0ee425 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ as a home-screen app, passkey sign-in, offline support, sync across your phone a - 🌍 **14 languages** — full UI translation (EN, DE, ES, FR, IT, PT (Portugal), PT (Brazil), PL, TR, RU, ZH, KO, HI, TH, HU); exercise instructions localized in 12 of them and built-in exercise names shown bilingually in PT-BR and HU, all loaded on demand so the app stays fast - 📥 **Bring your history with you** — import from **FitNotes** (Android and iOS), **Strong** and **Hevy** (CSV or directly with a [Hevy Pro API key](https://hevy.com/settings?developer)), or body weight straight out of an **Apple Health** export. Exercise names are matched against the library and anything unrecognised becomes one of your own exercises, so nothing in the file is dropped - 📻 **Radio while you train** — a **Radio** section in Música: live stations by genre (workout/rave, techno, R&B, Latin, hip-hop, reggae, chill, jazz, rock, electronic), the ad-free ones first — SomaFM and Radio Paradise — then the public [radio-browser](https://www.radio-browser.info) directory. It keeps playing across screens, with the screen locked and the phone in your pocket, and the lock screen shows the station and the track. **The audio goes straight from the station to your phone** — your server hands out the list and never proxies or stores a byte of it, and nothing is downloaded. No new dependencies. See [docs/RADIO.md](docs/RADIO.md) -- 🎙️ **Podcasts while you train** — a **Podcasts** section in Música: shows by category (health and fitness, sport, comedy, news, history, true crime, science, tech, society, business, fiction, education, music, leisure) from Apple's public directory, **in Spanish only** — and that is checked in each show's own feed, not assumed from the storefront it was found in. An episode is a file, so it resumes where you left off, marks itself heard, seeks back 15 s and forward 30 s, and plays the next one when it ends; the lock screen shows the episode and how far in you are. **Nothing is downloaded and no audio passes through your server** — the feed says where the file is and the phone goes and gets it. No new dependencies. See [docs/PODCASTS.md](docs/PODCASTS.md) +- 🎙️ **Podcasts while you train** — a **Podcasts** section in Música: shows by category (health and fitness, sport, comedy, news, history, true crime, science, tech, society, business, fiction, education, music, leisure) from Apple's public directory, **in Spanish only** — and that is checked in each show's own feed, not assumed from the storefront it was found in. An episode is a file, so it resumes where you left off, marks itself heard, seeks back 15 s and forward 30 s, and **continues with the next one when it ends**; tapping the bar opens the **full player** (artwork at size, a draggable scrubber, what is left, and what plays next), and the lock screen shows the episode, its progress, and its next/previous buttons. **Nothing is downloaded and no audio passes through your server** — the feed says where the file is and the phone goes and gets it. No new dependencies. See [docs/PODCASTS.md](docs/PODCASTS.md) - ❤️ **Salud: your Apple Health, live** — a **Salud** screen (the heart button in Home's header) draws whatever your iPhone reports: steps, heart rate, sleep, weight, oxygen, workouts and every other metric Health Auto Export can send, as cards with trends over 7/30/90/365 days. Per profile and private by construction — each profile mints its own **write-only** ingest key, the phone's data lands in its own file, and re-sends are de-duplicated, so an automation firing every five minutes never counts a day twice. See [docs/HEALTH.md](docs/HEALTH.md) - 📦 **Yours to keep** — one-tap JSON export/import, guest mode, **no telemetry**; switching kg ↔ lb offers to convert every stored number - 🤖 **Ask an AI about your training** (optional) — an [MCP server](mcp/README.md) lets a client like Claude Desktop or Cursor read your history in your own words: *"what did I bench last week?"*. Read-only, spawned locally by the client, nothing leaves your box. Not in the Docker build — if you don't use an AI assistant, it isn't there diff --git a/docs/PODCASTS.md b/docs/PODCASTS.md index 24640ef..0ac4d8a 100644 --- a/docs/PODCASTS.md +++ b/docs/PODCASTS.md @@ -78,6 +78,30 @@ sitting inside somebody's house: - Both routes need a session — not to protect public podcasts, but because this process fetches on behalf of whoever asks. +## The full player + +Tap the bar — the cover and the text, not the buttons — and it opens the full player, the way tapping +Spotify's bar does: artwork at size, the whole episode title, the show, the author, the episode number +and date, a **scrubber you can drag**, elapsed and **remaining**, −15 / +30, previous and next, and a +line that names **what plays next** ("Then: …") or says that this is the last one in the list. + +It opens as a **sheet**, not a route, for the same reason the bar lives above the router: a screen +inside the router is unmounted by navigating, and this must never be the thing that stops the audio. +Swipe down (or Android back) closes it and playback continues. + +A station gets the same sheet without the scrubber: a live stream has no position and no end, and +saying so is better than a slider that does nothing. + +## When an episode ends + +The next one in the list you tapped from plays, with nobody touching the phone. "Next" is literally +the next row of that list — the order you can see — and at the end of it playback stops, which the +full player says *before* it happens. The finished episode is marked heard first, so what you have +listened to stays that way. + +The lock screen's next/previous buttons do the same thing, which is the point: that is where somebody +with their hands on a bar is going to press it. + ## The player, and the two things that are easy to get wrong - **Audio only starts inside the tap.** iOS allows audio to begin from a user gesture and from diff --git a/docs/RADIO.md b/docs/RADIO.md index bfecc0c..256f0e6 100644 --- a/docs/RADIO.md +++ b/docs/RADIO.md @@ -83,6 +83,10 @@ rest timer, on purpose — a second floating bar with its own look reads as a se - **pause** — keeps the station, so the same one is still there after the rest - **stop** — takes the bar and the station away +Tapping the bar itself opens the full player — the logo at size, the station, its genre, what it +says it is playing, and pause/stop — with **no scrubber and no clock**, because a live stream has no +position and no end, and a slider that does nothing is worse than a sentence that says so. + **Media Session** is what puts the station, the track and the controls on the lock screen and in the car, and it is what makes "screen off, phone in pocket" work: the audio is played by the browser underneath the page, not by the page's timers. Those timers — the 45-second poll for what is playing — diff --git a/frontend/src/components/NowPlaying.jsx b/frontend/src/components/NowPlaying.jsx new file mode 100644 index 0000000..29397f6 --- /dev/null +++ b/frontend/src/components/NowPlaying.jsx @@ -0,0 +1,137 @@ +/* The full player: what the bar opens when you tap it, the way tapping Spotify's bar does. + * + * The bar is a glance — one line, under a thumb, over whatever screen you were on. This is the other + * half: the artwork at size, the whole episode title instead of the truncated one, a bar you can + * actually drag, and the number that decides whether to start something else (how much is *left*). + * + * It is a **sheet**, not a route, and that is the same decision as the bar living above the router: a + * screen inside the router is unmounted by navigating, and this must never be the thing that stops + * the audio. A sheet brings the house behaviour with it — swipe down to dismiss, Android's back + * closes it, the page behind it does not scroll — and `data-nodrag` on the scrubber (the Slider + * component already carries it) is what keeps a sideways drag from being read as a dismissal. + * + * Nothing here owns the audio: every control goes to the store, which goes to the one element in + * lib/player.js. + */ +import { useEffect, useState } from 'react' +import { useUI } from '../store/useUI.js' +import { t } from '../lib/i18n.js' +import { fmtClock, nextEpisode, prevEpisode, progressPct } from '../lib/podcast-view.js' +import { Slider, Button } from './ui.jsx' +import Icon from './Icon.jsx' + +export default function NowPlaying({ close }) { + const radio = useUI(s => s.radio) + const pod = useUI(s => s.pod) + const { togglePod, stopPod, podSeek, podSeekTo, podNext, podPrev, toggleRadio, stopRadio } = useUI() + + /* Stopped from somewhere else — the bar's ✕, or the end of the queue with nothing after it — and + this closes itself rather than staying open on an empty screen. */ + useEffect(() => { if (!radio && !pod) close() }, [radio, pod]) + + if (!radio && !pod) return null + + if (pod) { + const { episode, show } = pod + const duration = Number(pod.duration) || Number(episode.duration) || 0 + const next = nextEpisode(pod.queue, episode.id) + const prev = prevEpisode(pod.queue, episode.id) + return
+ + +
+
{show?.name || t('Podcast')}
+
{episode.title}
+
+ {[show?.author, episode.episode ? t('Episode {0}', episode.episode) : null, episode.date?.slice(0, 10)] + .filter(Boolean).join(' · ')} +
+
+ +
+ podSeekTo(v)} /> +
+ {fmtClock(pod.position)} + {/* What is left, not the total: the total is on the bar and on the right of the scrubber + a moment ago, and the question here is whether there is time for another one. */} + {duration ? '-' + fmtClock(Math.max(0, duration - (pod.position || 0))) : ''} +
+
+ +
+ + + +
+ +
+ + {(() => { + const pct = progressPct({ pos: pod.position, dur: duration }, duration) + return pct == null ? '' : Math.round(pct) + '%' + })()} + +
+ + {/* What plays when this one ends — or that nothing will. The queue is the list the episode was + tapped in, in the order it was shown, so "next" is the row below the one you pressed. */} +
+ {next ? t('Then: {0}', next.title) : t('Last episode in this list.')} +
+
+ +
+
+ } + + const station = radio.station + const cover = radio.now?.cover || station.image || null + return
+ + +
+
{t('Radio')}
+
{station.name}
+
{[station.detail, station.genre].filter(Boolean).join(' · ')}
+
+
+
+ {radio.now + ? t('Playing now: {0}', [radio.now.artist, radio.now.title].filter(Boolean).join(' · ')) + : t('This station does not publish what it is playing.')} +
+
+
+ +
+ {/* No scrubber, no clock, and saying so is better than a slider that does nothing: a live stream + has no position, no end, and nothing to go back to. */} +
{t('Live radio: there is nothing to seek and nothing to skip.')}
+
+ +
+
+} + +const Head = ({ onClose }) =>
+ + {t('Now playing')} + +
+ +/** The artwork at size — and the placeholder when there is none, which is a third of podcasts. */ +const Art = ({ image }) => { + const [bad, setBad] = useState(null) + return image && image !== bad + ? setBad(image)} /> + :
+} diff --git a/frontend/src/components/NowPlaying.test.jsx b/frontend/src/components/NowPlaying.test.jsx new file mode 100644 index 0000000..a4c5255 --- /dev/null +++ b/frontend/src/components/NowPlaying.test.jsx @@ -0,0 +1,191 @@ +// @vitest-environment happy-dom +/* The full player: the sheet the bar opens. + * + * Worth a test because it is mostly *claims* — "this is what is playing", "this is how much is + * left", "this is what plays next" — and a claim that drifts from the store is worse than no player + * at all. Two of them are load-bearing here: + * + * - **What plays next is named**, so continuing is not a surprise and stopping is not either. + * - **A station gets no scrubber.** A live stream has no position and no end; a slider that does + * nothing is worse than saying so. + * + * The `