feat(media): subtitles that travel with the film — CLI, browser <track>, ExoPlayer
`shade media put Film.mkv` seals Film.srt / Film.no.srt / Film.en.vtt found beside it and carries their grants in the film's sealed meta (extra["shade.subtitles"]), so they follow the film alone or in an album and the relay sees unrelated objects. /watch/ adds them as <track>s (SRT to VTT, labels in the viewer's language, the viewer's language on, one at a time); `media get` writes them back; Android opens them with ShadeMedia.openFilm and gives them to ExoPlayer as side-loaded tracks (ShadeMediaDataSource now resolves readers by URI). Verified: 76 TS tests; Chromium nb-NO shows the Norwegian track only, en-US the English one; film + subtitles round-trip bit-identical; Robolectric ExoPlayer sees both text tracks with the Norwegian one default; a shared vector checks the meta field in Kotlin (82/0). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -298,6 +298,30 @@ in TS, `Albums.parse` / `Albums.read` in Kotlin. The `/watch/` page shows an alb
|
||||
grid with decrypted previews, and Back returns from an item to its album. History
|
||||
entries hold only a depth, never a grant.
|
||||
|
||||
## Subtitles
|
||||
|
||||
`shade media put Film.mkv` also seals and uploads the subtitle files next to it, named
|
||||
the usual way: `Film.srt`, `Film.no.srt`, `Film.en-GB.vtt`. Their grants go into the
|
||||
film's own sealed meta, under `extra["shade.subtitles"]`:
|
||||
|
||||
```jsonc
|
||||
[{ "lang": "no", "label": "Norsk", "grant": { "kind": "shade.media-grant/v1", … } }, …]
|
||||
```
|
||||
|
||||
So the subtitles travel with the film, shared alone or inside an album, and the relay
|
||||
sees unrelated objects. In a directory, subtitles that belong to a video are not listed
|
||||
as album items of their own. `shade media get` writes them back next to the film as
|
||||
`Film.<lang>.srt`.
|
||||
|
||||
The `/watch/` page decrypts them through the worker, turns SubRip into WebVTT, and adds
|
||||
them as `<track>`s with names in the viewer's language. The track in the browser's
|
||||
language is on (Bokmål and Nynorsk match a `no` file), and only one is shown at a time.
|
||||
On Android, `ShadeMedia.openFilm(grant)` opens the film and its subtitle files, and
|
||||
`ShadeMedia.mediaSource(film)` gives them to ExoPlayer as side-loaded text tracks, the
|
||||
one in the device's language marked default. A subtitle that cannot be opened is
|
||||
skipped; the film plays without it. `withSubtitles` / `subtitlesOf` (TS) and
|
||||
`Subtitles.of` (Kotlin) read and write the field, checked against a shared vector.
|
||||
|
||||
## What the relay learns
|
||||
|
||||
- **Sealed:** that an opaque id exists, its size (to within a segment), when it was
|
||||
|
||||
Reference in New Issue
Block a user