Commit Graph

160 Commits

Author SHA1 Message Date
Álvaro Velad Galván 2d0469fb4a fix(VTT): Fix spacing between text lines (#4961)
Fixes https://github.com/shaka-project/shaka-player/issues/4958

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
2023-02-10 14:08:42 -08:00
Tom Bloom 9b1c614815 feat: Allow VTT files with erroneous linebreaks (#2394)
Bad linebreaks will now cause cues to be skipped (with a warning),
rather than throwing an error.

Closes #2358
Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2023-02-09 11:07:23 -08:00
Álvaro Velad Galván d4fc54f8dc fix(WebVTT): Tags in the WebVTT subtitle are not parsed (#4960)
Fixes https://github.com/shaka-project/shaka-player/issues/4956
2023-02-03 11:11:23 +01:00
Albin Larsson ed7a736ca2 feat(webvtt): webvtt colors output (#4954)
Adds color support for SimpleTextDisplayer and WebVttGenerator (only one
place to fix both now thanks to #4941).

It's limited to the [8 colors
classes](https://w3c.github.io/webvtt/#default-text-color) supported by
the WebVTT specification, and also works with their 3 or 6-digit hex
variants (if the stream has TTML subtitles).

It does not support rgb, rgba or any colors other than these 8.

Fixes #4545

---------

Co-authored-by: Alvaro Velad Galvan <ladvan91@hotmail.com>
2023-02-03 09:34:16 +01:00
Joey Parrish f45631834d fix(WebVTT): Fix horizontal positioning with cue box size (#4949)
When the VTT size setting is used, the horizontal positioning was wrong
in both native and UI display.

The native display is wrong on Chrome and Edge because of a layout bug
in Chrome, where the shadow DOM for the cue box has conflicting
(redundant) styles. For example, these VTT settings:

`line: 85% position: 50% size: 63%`

result in these styles in the shadow DOM:

`top: 85%; left: 18.5%; transform: translate(-18.5%, -85%)`.

The `translate` style is what breaks the positioning. Unfortunately,
there is no way to fix that in JavaScript.

The UI display, however, was buggy for different reasons and is fixable.
The styles `left: 0; top: 0;` were applied by default, and then `top:
85%;` and `width: 63%;` were set based on the cue settings. The default
of `left: 0` was what broke the positioning. Removing this leaves `left`
set implicitly to `auto`, which is correct.

No other test cases were broken (or fixed) by this change.

This also adds a filter parameter to the lab workflow to run a subset of
tests for quicker results. This is useful for updating screenshots.

Closes b/259121343
2023-01-30 16:01:25 -08:00
Joey Parrish 7c4ed53410 test: End-to-end WebVTT layout tests (#4935)
Many of these are rendered incorrectly in some way.

This PR contains only the tests, but not the screenshots, to make the
tests easier to review. The screenshots will appear in a separate PR.

Related to work on PR #4767
2023-01-26 14:09:16 -08:00
Álvaro Velad Galván 68968c17d8 fix(WebVTT): Fix voices with styles and support to multiple styles (#4922) 2023-01-24 19:53:48 +01:00
Álvaro Velad Galván 726ef425b0 fix(WebVTT): Add support to &nbsp;, &lrm; and &rlm; (#4920) 2023-01-20 23:41:51 +01:00
Joey Parrish da84a2c86b fix: Fix WebVTT parser failure on REGION blocks (#4915)
We do not yet support VTT region settings, but we should still not fail
when a region block appears in a VTT file.

Related to work on PR #4767
2023-01-19 11:53:22 -08:00
Álvaro Velad Galván a5f8b4361e feat(WebVTT): Add support to voice tag styles (#4845)
closes https://github.com/shaka-project/shaka-player/issues/4844
fixes https://github.com/shaka-project/shaka-player/issues/4843
fixes https://github.com/shaka-project/shaka-player/issues/4479
2023-01-19 11:35:21 +01:00
Joey Parrish dd860fab9f chore: Organize screenshots by suite (#4908)
There is currently only one suite, but that is about to change. This
renames all screenshots to include the name of the suite, and updates
the review page with a temporary hard-coded suite name.

Related to work on PR #4767
2023-01-17 15:47:40 -08:00
Joey Parrish dcc94b163f chore: Rename layout tests (#4907)
Also fixes a compiler error that comes up for some reason when renaming
the other tests. The compiler will accept an assignment to nestedCues,
but not pushing to it. I was unable to fix the missing type information
for this.

Related to work on PR #4767
2023-01-17 15:31:39 -08:00
David HM Morgan 5681efe95c fix: Treat regions uniquely (#4841)
Captions split over stream segment boundaries are repeated over more
than one segment.
Regions in which they sit maybe described the same but allocated
different ids and vice versa.
Proposal to treat internal region ids uniqely by encoding the dimensions
in the id.

fixes #4839
2022-12-15 19:23:41 +01:00
Joey Parrish bd75032d63 fix(TTML): Fix duplicate cues overlapping segment boundaries (#4798)
Closes #4631
2022-12-08 09:05:08 +01:00
David HM Morgan 4081434eba fix: Fix subtitles not added to DOM region (#4733)
Reinstate previously removed region elements when next caption finds it
is not there: Detect the absence and ensure `updateDOM` is true so its
reinstated and the next caption can be shown.

Closes #4680

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-12-07 14:23:12 -08:00
Álvaro Velad Galván 2b8b38788a feat: Support HTML-escaped cues in VTT (#4660)
Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-11-09 16:02:46 -08:00
Joey Parrish 3b9af2efa6 fix: Fix HLS live stream subtitle offsets (#4586)
Subtitle timing and offsets were not calculated correctly for HLS live
streams. This issue appears to have affected all v4.x releases up to
v4.0.5, v4.1.5, and v4.2.2.
2022-10-17 19:27:55 -07:00
Joey Parrish 32b0a90a8c fix(ttml): Default TTML background color to transparent if unspecified (#4496)
Closes #4468
2022-09-27 19:51:46 -07:00
Joey Parrish b1f46dbc3a fix(text): Fix cue region rendering in UI (#4412)
Both TTML and VTT regions should be thought of as separate elements
from the cue structures they contain.  To this end, the UI text
displayer now creates separate region elements to represent CueRegion
objects, and the Cues attached to them nest inside those region
elements in the DOM.

Closes #4381
2022-08-16 16:37:17 -07:00
Julian Domingo 122f223d19 fix(text): Fix TTML render timing and line break issues (#4407)
This changes the `SimpleTextDisplayer` to flatten text payloads
only starting at non-container cues. Not doing so poses an issue with
'rolled over' caption lines.

E.g., consider:
- TTML file `N` with caption line `A` from time `[1.4, 2.1]`.
- TTML file `N+1` with caption lines `A` from time `[1.4, 2.4]` and `B` from time `[2.4, 3.4]`.

If captions `A` and `B` are descendants of two different `<p>` elements, Shaka
currently flattens the text payload from `A` and `B` into a single cue that is
rendered onto the display from time `[1.4, 3.4]`. Therefore, caption `A`'s text
payload is incorrectly showing during time `[2.4, 3.4]`.

The fix updates the `SimpleTextDisplayer#append()` logic to split up individual 
non-container cues into their own `VTTCue` object. This will not be done at the 
`TTMLTextParser` level to ensure proper style inheritance still occurs for the 
(actual) text cues.

Closes #4381
2022-08-15 20:56:12 -07:00
Álvaro Velad Galván 60af516520 feat(webvtt): add support for karaoke style text in WebVTT (#4274)
Closes https://github.com/shaka-project/shaka-player/issues/4264
Closes https://github.com/shaka-project/shaka-player/issues/3893
2022-06-07 11:12:33 +02:00
Álvaro Velad Galván 62bda2cd36 feat: Add support to text-shadow in VTT parser (#4257) 2022-05-27 07:52:55 +02:00
Joey Parrish 58182605a7 fix: Fix VTT cue timing in HLS (#4217)
Since the transition to sequence mode for HLS in v4.0.0, VTT cue
timings were broken.  This is mainly because VTT cue timing in HLS is
meant to be based on an offset from the media timestamps, and we
generally don't know those now that we use sequence mode.

To fix it, this change uses MediaSource segment mode for the very
first video segment as a way to extract the timestamp, then clears the
buffer, switches to sequence mode, and appends it again.  This lets us
get the timing data we need, while avoiding major drawbacks of the
previous HLS implementation:
 - We don't need to fetch segments upfront (which is high latency)
 - We don't need to fetch segments twice (once for timestamps, and
   once again to buffer)
 - We don't need to maintain parsers (which were complex and limited
   the formats we could support)

Closes #4191
2022-05-11 15:26:02 -07:00
Joey Parrish 1eadfd1e20 test: Improve TextDisplayer test reliability and timing (#4136)
This seems to reduce flakiness in the TextDisplayer tests.  The
theory is that Safari throttles timers when the system is very busy,
which it often is during full test runs across multiple browsers.  By
not relying on timers and triggering an explicit update in the
TextDisplayer, the tests seem to become more reliable.
2022-04-19 10:47:39 -07:00
Joey Parrish fbbd63d96b test: Late load tests, fix Chromecast test flake (#4115)
This change fixes tests on Chromecast by loading tests later in the process.  Test scripts are now dynamically inserted by boot.js, rather than loaded by Karma.  The bootstrapping code then awaits the completion of that before starting the Karma frameworks (Jasmine) to run the tests.

This also removes the use of goog.provide/goog.require in tests and test utils.  We don't need to load test utils or library sources dynamically in each test, and this gives us more explicit control over script loading and ordering.

Closes #4094
2022-04-11 15:47:48 -07:00
Philippe f382cc702b feat: add option for segment-relative VTT timings (#4083)
This PR fixes #3242 where for some live streams using segmented VTT, text timings are relative to segment start instead of being absolute.

The PR introduces a new setting: `manifest.segmentRelativeVttTiming: boolean` allowing such alternative timing offset calculation.

The setting is off by default, preserving the current player behaviour.

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-04-01 09:39:11 -07:00
Joey Parrish 1507b1e844 chore: Update URLs after moving projects (#4008) 2022-03-03 14:34:40 -08:00
theodab a4e926772e fix(text): Fix webvtt offset in sequence mode (#3955)
When running in sequence mode, we ignore the normal timestamps
of video and audio segments. This lead to problems in some Apple-
encoded webvtt content, which used the X-TIMESTAMP-MAP tag to account
for the timestamp offsets in their video. Thus, those subtitles would
end up 10 seconds offset.

This changes the webvtt parser to ignore the X-TIMESTAMP-MAP when in
sequence mode.

Issue #2337
2022-02-16 11:38:20 -08:00
Álvaro Velad Galván 0635e2c055 fix: Fix compiler error introduced in #3864 (#3906) 2022-01-26 09:53:08 -08:00
Theodore Abshire e9df8fb10c fix(text): Inherit alignment from regions.
The recent changes to TTML parsing, to not inherit regions,
inadvertently ended up breaking text alignment in situations
where a region with alignment was on the p or div above a span.
Previously, we only inherited the text and display alignment
from a region on leaf nodes... which was a problem, since we
also didn't apply any styles to text nodes.

Change-Id: I62ac155bc4310a5f7da52c10ca2dd434f8015c97
2022-01-25 21:39:21 +00:00
Álvaro Velad Galván 771619ff0e fix: Fix support for TTAF1 namespace (old version of TTML) (#3864)
Fixes #3009
2022-01-25 10:40:13 -08:00
Theodore Abshire bf67d87387 fix(text): Fix caption overlap.
This changes the TTML parser to not allow cue regions to be inherited
to the children of the element the region was originally assigned on,
except for the purposes of styles (colors, etc).
To allow regions on elements "above" the cues in TTML, such as the
<body> or <div> elements, this also changes the TTML parser to render
the full structure of the TTML file as a tree of cues. The end result
will be a single cue representing the <body>, with children
representing the <div> elements inside it, and those <divs> will have
children that represent the actual cues. Now that our text displayer
can intelligently update child cues as they enter or leave the display
window, this approach should be possible.

Closes #3850
Closes #3741

Change-Id: Ia8d750daa06920610c04e9b26e29d2d304eaf8a9
2022-01-20 22:41:37 +00:00
Álvaro Velad Galván 3ff48cba9b fix(text): Made nested cues inherit region (#3837)
Closes #3743
2022-01-12 12:45:24 -08:00
Álvaro Velad Galván c5a81f53fe fix(text): Allow comments in the TTML parser (#3827)
Closes #3766
2022-01-04 11:34:44 -08:00
Theodore Abshire 4bdd3bb65a fix(text): Force caption update when removing cues
Previously, in the updateCaptions_ method in the UI text displayer,
when trying to determine if a cue should be removed from the container,
we checked to see if it was out of the time range.
This worked in most cases, but it did have the side-effect that the
displayer would not remove the old cues if they were removed manually
via the remove() method. This was most visible if the user changed the
text language; the currently-displayed cue of the old language would
linger until it reached the point it would stop displaying normally.
This changes the UI text displayer to force an update when remove() is
called, if necessary.

Change-Id: I84a4847b67c5fb7597342a943abe13a3cc9e826e
2021-12-06 18:33:54 +00:00
Jacob Trimble cdeffbb9e6 fix(ui): Fix styling of UI text cues
First, the positioning of cues was incorrect.  We need to explicitly
set all the position attributes when we position elements with the
"absolute" position.

Second, if we position a text <span> manually, the background will fill
the whole region.  So to keep the background wrapping the text, we need
to add another <span> for the text.

Third, the background and font color should not be set on every <span>
element since it won't allow parent cues to set the inherited value.
So this moves the defaults to the top-level text element and allows
parent cue elements to override this.  It also would make app CSS
easier to override.  Because background color isn't inherited through
CSS, the default is set in JavaScript instead.

Fixes #3521
Fixes #3600
Closes #3713

Change-Id: I45fc88dcac4a0a062e1474087f24c80d98eef619
2021-11-03 17:31:25 +00:00
Theodore Abshire 7da2cd59ff fix(text): Fix UI test failures
A new UI test added in a recent CL involved manually setting the
currentTime value of a videoElement in tests.
For some reason that wasn't working on Safari, so this changes that
UI test to use a fake video instead of a real one.

Closes #3689

Change-Id: I412f677f6cda49bbfc850a9102edfe3b75bca302
2021-10-08 16:19:06 -07:00
Theodore Abshire b02ff27017 fix: Fixes updating of nested cues
Previously, we added support for respecting the time constraints
of nested cues. However, the UI text displayer did not take the
time constraints of nested cues into account when determining when
and how to update the cues.
This changes the UI text displayer to also do that.

Issue #3524
Issue #3643

Change-Id: I6b643f2aa21f367a8e40a8aca2ebb62492c071c2
2021-10-06 14:50:11 -07:00
Theodore Abshire 157bd77be2 fix(ttml): Fix ttml erroneously dismissing cues.
When trying to detect if it is appropriate to ignore a non-break
element, the ttml parser would base the decision on the presence
of timing info in the cue itself, and on the presence of
textContent within the node. If neither is present, the element
might be ignored.
This works in most cases of nested cues, as the presence of text
within a child node will show up in the textContent of the parent
node. However, not all valid ttml cues have textContent; image
cues, for example, have their contents defined as a DOM attribute.

This changes the ttml parser to not ignore any cue that has child
cues. It also changes the ttml parser to cause cues with no defined
timing to base their timing on their child cues, if present.
This also changes our UI text displayer to respect the timing info
of child cues.

Closes #3643

Change-Id: I9a017f53398bbed8dbeeeebca2cff76dd3666c64
2021-09-29 21:53:41 +00:00
Theodore Abshire 911ce6d250 feat(text): Partially support tts:textOutline
Unfortunately, modern browsers do not support any CSS property that
directly maps to tts:textOutline. However, the non-standard (but still
commonly implemented) -webkit-text-stroke-width and
-webkit-text-stroke-color properties, when used together, can
replicate the functionality of tts:textOutline, with the exception of
the optional blur radius.

Closes #3612

Change-Id: I863d09fc447765646bd405c59b0b20960362a594
2021-09-14 12:05:39 -07:00
Álvaro Velad Galván a7f4db7f18 fix: Account for server-side ad cue points in external text tracks. (#3617)
When an external subtitle track is added and you are using DAI, the external track does not take into account the ads that the video has, so this PR makes this internally take into account when generating the external track.
2021-09-13 15:39:06 -07:00
bcupac 65e9d8ff85 fix: Display captions with forward slashes (#3556)
Closes #3555 .
2021-08-15 22:30:22 -07:00
Joey Parrish 2250324a4a fix: Fix enforcement of cue alignment styles
This uses flexbox once again to get proper positioning of cues.  To
compensate for the issues that originally made us remove flexbox, this
adds a wrapper span inside the flexbox element.

Summary of screenshot changes:
 - slight change to background sizing
   - ui-basic-cue
   - ui-cue-with-controls
   - ui-duplicate-cues
   - ui-end-time-edge-case
   - ui-flat-cue-bg
   - ui-two-basic-cues
 - background fills block with literal newline in text
   - ui-cue-with-newline
 - region anchored without padding
   - ui-region-position
 - new screenshots
   - *-nested-cues-with-linebreak
   - *-region-with-display-alignment  (regression test for this issue)

Closes #3379

Change-Id: I8c678721d96662e0f8940cda12df4f5b5e5baf1e
2021-07-09 17:19:42 +00:00
Álvaro Velad Galván 9ffc111c49 feat: Add align and vertical settings to WebVttGenerator (#3413) 2021-05-17 13:30:08 -07:00
Michelle Zhuo 95ba28b5af refactor: Remove IE 11 support
Issue #2339

Change-Id: I80ffa7b04f7afd943aa0f881d2a494dd35def732
2021-04-29 17:47:07 +00:00
Joey Parrish fff9a96958 fix(UI): Fix writing-mode on Tizen 3
Old versions of Chromium, which may be found in certain versions of
Tizen and WebOS, may require the prefixed version of "writingMode":
"webkitWritingMode".

However, testing shows that Tizen 3, at least, has a "writingMode"
property, but the setter for it does nothing.

Therefore, instead of just detecting the existence of the property, we
need to additionally check if setting it had any effect.  If it is
either missing or non-functional, then we fall back to the prefixed
version of the property.  This fixes the functionality on Tizen 3.

We also need to change the conditions we check for in the tests, since
property existence is not enough to set the correct test expectation.

See also PR #3330

Change-Id: Ic906f3c5af956b5edd1788e95e1978eb4b3098ac
2021-04-22 17:09:25 +00:00
Álvaro Velad Galván 7af44ef565 fix(UI): Fix writing-mode support in old versions of Tizen and WebOS (#3330) 2021-04-19 10:44:17 -07:00
Álvaro Velad Galván 463b1b6886 Remove support for IE 11 (#3309)
Issue #2339
2021-04-16 13:59:35 -07:00
Álvaro Velad Galván 9f54c41860 fix(TTML): fix image subtitles parsing in TTML (#3294)
TTML allows "smpte:backgroundImage" on both the div level and p level. Adding parsing the background images into cues on the div level.

Closes: #3097
Closes #3248
2021-04-01 14:40:01 -07:00
Álvaro Velad Galván 658790a012 feat(text): Creates style tags for underline/italics/bold in WebVttGenerator (#3266) 2021-03-30 11:02:02 -07:00