LanguageValues and typesStandard typesMedia and visual
SubtitleCue
On this page
A timed caption: when it starts and ends, and its text.
Use it for subtitles, as WebVTT holds them.
Shape
Its parts keep these rules, and a value that breaks one fails with the rule's name:
start_not_negative: start >= 0msend_after_start: end > starttext_without_arrow: text holds no-->
Example
SubtitleCue { start: 1s end: 4s text: "Never drink liquid nitrogen." }text.parse(raw, as: SubtitleCue) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as 00:00:01.000 --> 00:00:04.000.
Good to know
- Times count from the start of the media. The end must be after the start, and the text can't hold
-->. ==tells you whether two are the same.<andlist.sort_bydon't take it, so sort by one of its parts instead.
In JSON
An object of its parts, in a request, a response or json.write:
{"start":"PT1S","end":"PT4S","text":"Never drink liquid nitrogen."}{"start":"PT1M5.25S","end":"PT1M7.5S","text":"— It will perforate your stomach.\n— You could die."}{"start":"PT100H","end":"PT100H0.001S","text":"End"}
Details
Text form, storage, how it is shown, and operations
SubtitleCue is in the group Media and visual, and has been in Jadpo since 0.1.0.
Text form
text.from writes one standard text form, the same form text.parse reads back: 00:00:01.000 --> 00:00:04.000\nNever drink liquid nitrogen., 00:01:05.250 --> 00:01:07.500\n— It will perforate your stomach.\n— You could die. and 100:00:00.000 --> 100:00:00.001\nEnd.
How it is stored
It is stored in 3 columns, each named for the field, _ and its suffix. This is 00:01:05.250 --> 00:01:07.500\n— It will perforate your stomach.\n— You could die.:
| Column | Type | Holds |
|---|---|---|
<field>_start |
bigint |
65250 |
<field>_end |
bigint |
67500 |
<field>_text |
text |
E'— It will perforate your stomach.\n— You could die.' |
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
"00:00:01.000 --> 00:00:04.000\nNever drink liquid nitrogen." |
"00:00:01.000 --> 00:00:04.000\nNever drink liquid nitrogen." |
"00:01:05.250 --> 00:01:07.500\n— It will perforate your stomach.\n— You could die." |
"00:01:05.250 --> 00:01:07.500\n— It will perforate your stomach.\n— You could die." |
"100:00:00.000 --> 100:00:00.001\nEnd" |
"100:00:00.000 --> 100:00:00.001\nEnd" |
Operations
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-subtitle-cue.md.Built from Jadpo main at aee2e8f.