Files
dsantillan 78b815ae8f
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
El reproductor completo al tocar la barra, y el episodio siguiente al terminar
Tocar la barra abre el reproductor completo, como el de Spotify: portada en grande,
título entero, programa, autor, número de episodio y fecha, una barra que se arrastra,
el tiempo transcurrido y **lo que falta**, −15/+30, anterior y siguiente, y una línea
que dice **"Después: …"** con el nombre del que sigue —o que es el último de la lista.
Es una hoja, no una ruta, por lo mismo de siempre: una pantalla dentro del router se
desmonta al navegar y esto no puede ser lo que corte el audio. Para una emisora el
mismo reproductor no dibuja barra de progreso: una radio en vivo no tiene posición ni
final, y decirlo es mejor que un slider muerto.

Un episodio que termina **sigue con el siguiente** de la lista en la que lo pusiste a
sonar, sin tocar el teléfono; al final de la lista se detiene y el reproductor lo
avisa antes. El que termina queda marcado como escuchado. Los botones de siguiente y
anterior de la **pantalla bloqueada** ahora llegan al elemento de audio, que es donde
alguien con las manos en la barra los va a apretar.

Y dos cosas que aparecieron revisando esto:

- `setRadioNow` llamaba a `setMediaSession`, una función que ya no existe desde que el
  reproductor se unificó (hoy `setStreamSession`). El error quedaba **tragado** por el
  `.catch` del sondeo: la pantalla mostraba el tema —el estado se actualiza antes de la
  línea que falla— y la **pantalla bloqueada nunca se enteraba** del tema que sonaba.
  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 había quedado duplicado el final del bloque de radio, y en un
  objeto literal la última gana en silencio. Una copia era código muerto que se leía
  como vivo — y fue la que hizo que el primer intento de comprobar lo anterior "pasara".

Tests nuevos: useUI.podcast.test.js (16, con el reproductor burlado emitiendo lo que
emite un navegador: ended → siguiente, time → reloj, paused → posición guardada),
NowPlaying.test.jsx (13) y el toque en la barra en PlayerBar.test.jsx.
2026-09-23 21:40:17 -04:00

8.1 KiB
Raw Permalink Blame History

Podcasts

Radio, but the other half of it: episodes, in Spanish, that you can resume.

Open Música → Podcasts (the middle tab; the screen shows one list at a time, ten shows with a "show more"), search by name if you know what you are looking for, or pick a category (Salud y fitness, Deporte, Comedia, Noticias, Historia, Crímenes reales, Ciencia, Tecnología, Sociedad y cultura, Negocios, Ficción, Educación, Música, Ocio), tap a show, tap an episode. It plays across screens, keeps going with the screen locked, and comes back where you left it.

Why podcasts and not just more radio

They are opposites in every way that matters to the player, and the difference is not cosmetic:

Radio A podcast
Source a live stream a file with a beginning and an end
Position meaningless the feature
Pause pause the stream pause, resume, seek ±, remember
Playing next the station's job yours: next episode
Length unknown, forever minutes, and worth showing

A podcast you cannot scrub is a podcast you do not use, which is why the player bar grows a progress hairline and two seek buttons when an episode is playing, and none of that exists for a station.

A search is not a weaker way in

Typing in the box above the tabs asks Apple's podcast search, both storefronts, and the results go through the same feed check and the same Spanish filter as a category's chart entries — one function on the server, used by both, so "Spanish only" cannot quietly stop applying to a search. That is the shape worth keeping: a second, cheaper path into a catalogue is how a rule like this gets lost.

Spanish only — checked, not assumed

The user asked for Spanish, so the app checks, and this is the part worth knowing before trusting a short list:

  • Apple's directory is browsed per storefront (es and mx). A storefront says where a podcast is sold, which is not the same as the language it is in: the Spanish comedy chart carries a Catalan show, and the Argentine one carries an English show.
  • So every show's feed is read — its first 64 KB, with a Range request, because <language> is channel metadata that sits in the first ~1.5 KB and always before the first <item> — and its <language> decides. es, es-ES, es-419 and spa stay; ca, en, pt and the rest go.
  • A feed with no tag at all stays. Some genuinely Spanish feeds omit it (La Ruina does), and dropping them over an omission would quietly remove good podcasts; the storefront is the fallback signal, and it is not a guess.
  • The response says how many shows were dropped and why (skipped: { duplicate, language, unreadable, failed }), so a list of fifteen is never a mystery.
  • Opening a show re-checks against the whole feed, and a show in another language is answered with spanish: false and a sentence — not with an empty episode list that looks like a feed with nothing in it.

Nothing is proxied, and nothing is downloaded

An episode arrives as an https:// URL from the publisher's own enclosure, the phone plays it, and the bytes go from the publisher to the phone. This server contributes the list, exactly the bargain the radio makes — no audio through the container, no copies, no downloads, no disk.

What this does cost, server-side, is requests: Apple's charts and lookup (two per category), one 64 KB Range request per show to read its language, and one fetch per feed when a show is opened (up to ~6 MB for a big archive — cached for half an hour, parsed, and the parsed episodes are what is kept, never the body, because forty episodes are a few kilobytes and a feed is megabytes).

What may be fetched

Radio has a host allowlist because it talks to three services. Podcasts cannot: feeds live on every host in the world. So this is the other rule, and it is the rule that matters for an api container sitting inside somebody's house:

  • https only, no credentials in the URL, a real hostname and never a private address — no loopback, no 10./192.168./172.16-31., no carrier-grade NAT, no link-local (the 169.254.169.254 metadata address is the classic target), no IPv6 literals, no .local or .internal.
  • The URL is checked and so is where the request ended up, because a redirect is otherwise the way around it.
  • Bodies are read with a cap and the connection is dropped the moment it is reached.
  • 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 nothing else, so nothing asynchronous may sit between the finger and the play(): the episode URL is already in hand, and the store's playEpisode calls straight through.
  • The <audio> element lives outside React (frontend/src/lib/player.js), shared with the radio, so changing screens does not stop it and two kinds of media can never play at once.

Positions are saved to your profile — per episode, throttled to once every few seconds, and always on pause, on stop, when an episode ends and when the app goes to the background. That last one matters: iOS suspends a locked page's timers, so a position saved only from a tick would lose whatever was played with the screen off.

Episodes count as heard when they are within twenty seconds of the end, and starting one of those begins it again rather than resuming into its last seconds. Two hundred positions are kept per profile, newest first.

The screen locked, and the native shells

Safari and the installed PWA keep playing with the phone locked, and Media Session puts the episode, the show and the progress bar on the lock screen, with the controls reaching the same audio element. The two shell builds need configuration for that (see MOBILE.md) — in the PWA, nothing.

What this deliberately is not

  • Not a downloads app. There is no offline mode and no stored audio: the episode plays from the publisher every time, which is also why nothing here will ever be a copyright question.
  • Not Apple Podcasts' API. There is no such thing for third parties; the directory and the feeds are public, and that is what this uses — no key, no account, no Apple ID.
  • Not a proxy or a transcriber. No audio through the server, no speed-up, no ad-skipping.
  • Not a general podcast directory. Spanish is a filter, not a preference to be toggled.

Credits

  • Apple Podcasts directory — the charts and lookup used to find shows and their feeds. Public, keyless endpoints; the shows and episodes are the publishers' own.
  • The shows themselves belong to the people who make them; the audio is served from their hosts.