Commit Graph

227 Commits

Author SHA1 Message Date
Álvaro Velad Galván 56ac70d44a perf(S2T): Improve SpeechToText code (#9718)
Avoid race conditions when using Translator API.
Avoid unnecessary DOM mutations.
Separate responsibilities in the code.
2026-02-17 10:07:29 +01:00
Álvaro Velad Galván afd24224ce feat(SRT): Improve SRT to WebVTT conversion and color handling (#9624)
- Full SRT → WebVTT conversion now supports timestamps, alignment,
position, and basic styles (bold, italic, underline).
- Added proper handling for <font color="..."> tags:
  - Converts known colors to WebVTT <c.color> classes.
  - Safely removes unknown colors without leaving orphaned </c> tags.
- Supports Aegisub cues ({\anX} → line & align, {\pos(x,y)} → position &
line).
- Normalizes timestamps (MM:SS,mmm → 00:MM:SS.mmm) for WebVTT
compliance.
2026-01-29 12:39:38 +01:00
Álvaro Velad Galván aaecc079be fix(TTML): Fix MP4 TTML Parser producing invalid image subtitles (#9559)
Fixes https://github.com/shaka-project/shaka-player/issues/9557
2026-01-14 12:01:02 +01:00
Álvaro Velad Galván c4de8f1f53 fix: Fix alignItems usage on old devices (#9544)
start/end are supported from Chromium 93+ (see:
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/align-items).
2026-01-05 15:04:13 +01:00
Gary Katsevman 2d23ea456a fix: don't clear text displayer cache for vtt if we're clearing cea cache (#9538)
an issue we found as part of making the fix for #9470 and also
separately.
2025-12-23 15:43:33 +01:00
Álvaro Velad Galván c6e6082bc2 feat: Allow override subtitle position (#9522)
Close https://github.com/shaka-project/shaka-player/issues/9521

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
2025-12-19 13:38:33 +01:00
Álvaro Velad Galván d5be5d6f45 feat!: Text displayers should receive a shaka.Player pointer (#9515)
Related to https://github.com/shaka-project/shaka-player/issues/9301
2025-12-17 10:11:00 +01:00
Álvaro Velad Galván 84dccd38f5 fix: Fix external text track timing when using HLS (#9511)
Fixes https://github.com/shaka-project/shaka-player/issues/9510
2025-12-16 14:58:04 +01:00
Álvaro Velad Galván 86bfea08aa feat!: Move speech to text to the accessibility section in config (#9507) 2025-12-16 12:37:44 +01:00
Álvaro Velad Galván 4bc2518e29 feat!: Remove LRC, SBV, SSA support (#9330)
Related to https://github.com/shaka-project/shaka-player/issues/9321
2025-11-04 20:07:02 +01:00
Álvaro Velad Galván 8e0e0d85c1 feat!: Remove setSequenceMode from TextParser plugins (#9326) 2025-10-31 16:14:52 +01:00
Álvaro Velad Galván 7f662a15b9 feat!: Remove enableTextDisplayer from TextDisplayer plugins (#9311)
This is no longer necessary since we have removed
shaka.text.SimpleTextDisplayer
2025-10-29 16:43:06 +01:00
Álvaro Velad Galván 945c57ab77 feat!: Remove all deprecated things (#9162) 2025-10-07 10:52:13 +02:00
Álvaro Velad Galván 61d80f6e59 feat: Add automatic subtitles (#9123)
Internally this uses Web Speech API
https://webaudio.github.io/web-speech-api/ and Translator APIs
https://webmachinelearning.github.io/translation-api/

The feature is experimental and disabled by default since Chrome is the
only browser that currently supports it.

Closes https://github.com/shaka-project/shaka-player/issues/9110

---------

Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
Co-authored-by: Theodore Abshire <TheodoreAbshire@Gmail.com>
Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2025-09-26 13:18:44 +02:00
Wojciech Tyczyński f128e2261a perf(CEA): Remove captions attached to removed segments (#9068)
TextEngine was storing closed captions and releasing them only on
teardown. This might be a potential memory leak for long running
sessions.
This PR addresses it by removing cached captions along with removed
segments. Furthermore, it adds some more tweaks and improvements, such
as:
- simplify CEA cache structure, from `Map<string, Map<string,
Array<Cue>>>` to `Map<string, Array<Cue>>`
- adjust TextEngine buffered ranges with cached cues values
2025-09-09 11:26:48 +02:00
Álvaro Velad Galván 3618d4f4ca fix: Only create shaka-text-container when necessary (#8581) 2025-05-09 22:05:39 +02:00
xiao 724b0b2a71 feat: new TextDisplayer implementation to allow selecting subtitles via native API and controls (#8520)
Close https://github.com/shaka-project/shaka-player/issues/8519
Fixes https://github.com/shaka-project/shaka-player/issues/8475

Introduce `NativeTextDisplayer` as a replacement of
`SimpleTextDisplayer`. But keep them both work.
Is MSE mode, `NativeTextDisplayer` creates `<track>` elements for text
streams. And listens to change events on both ends to keep them in sync.
In SRC mode, `NativeTextDisplayer` would do nothing, the player uses
original TextTracks instead.

Advantages of `NativeTextDisplayer`:
- Allow text track selection using the browser built-in UI
- Allow text track manipulation using native APIs
- Avoid transferring and processing cues in SRC mode

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-05-07 12:58:29 +02:00
Álvaro Velad Galván 1c8539698c feat(UI): Modernization of the UI (#8409)
Changes:
- The look has been changed to make it more similar to YouTube:
  - The main background color is now black, and the font is white.
  - Presentation time has been moved to the bottom.
  - Cast and airplay buttons are now more accessible.
  - Tooltips have been enabled except on mobile platforms.
- The ad information has been moved to appear in the same position as
the presentation time when the ad is present.
- A mark indicating the current quality has been added (e.g.: HD, 2K,
4K, 8K)
- The spinner has been replaced with one that works well on Smart TVs
and is very similar to the current one. The animation is included in the
SVG element itself rather than through CSS.
- More LESS variables have been added to make customization easier in
forks.
- The maximum size of the menus is dynamically calculated so that they
never extend outside the video container.
- The size of the subtitle container when the UI appears is now
calculated dynamically.
- The Demo has been updated to show the seekbar when trickplays are
enabled.
- UI performance on Smart TVs has been improved (Tested on Tizen 5.0)
- Many offsets that were hardcoded have been removed, but not all (in
CSS).

Close https://github.com/shaka-project/shaka-player/issues/8406
2025-04-08 13:46:23 +02:00
Wojciech Tyczyński 51ff82f204 build: Migrate to stylistic eslint plugin (#8298)
Fixes #8278
Migrates deprecated rules from `eslint-config-google` and our rules as
well to stylistic.
Additionally removes broken `eslint-disable` python check and replaces
with eslint `reportUnusedDisableDirectives` option.
2025-03-19 16:18:30 +01:00
Álvaro Velad Galván c8747ab0b8 feat: Move caption scaling from css to new textDisplayer.fontScaleFactor config (#8242)
Fixes
https://github.com/shaka-project/shaka-player/pull/8215#issuecomment-2711266477
2025-03-12 13:16:48 +01:00
David HM Morgan 18695c6c23 feat: Text font scaling customisation ability (#8215)
With reference to #8025, this is a partial proposal to see if this style
of extensible customisation could be favourable to the shaka-player
community:

Proposal for some accessibility options whereby an App builder can
customise subtitle/caption size, with the potential of an App offering
accessibility options for text size.

This style could be used for other text styling attributes in a similar
way, but this is just the first step.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2025-03-06 13:44:49 +01:00
Álvaro Velad Galván 356de09850 perf(UI): Avoid unnecessary calls to controls configure (#8116) 2025-02-19 15:45:26 +01:00
Juliane Holzt 2562384055 fix(TTML): Correctly handle multiple samples in a segment (#8088)
Fixes https://github.com/shaka-project/shaka-player/issues/8087

Implements handling of multiple samples in a MP4/ISOBMFF/DASH TTML
segment/fragment. Such segments are allowed by ISO14496-12 and
ISO23000-19. gpac creates such segments. The prior code just treated the
full MDAT as one TTML XML document and tried to parse it in whole
without accounting for sample(s). A testcase is included which was
created by taking the testdata from ttml-segment.mp4 and splitting the
subtitles into two independent TTML-XML documents, which then were put
as individual samples.

The testdata for the prior existing multiple MDAT testcase was invalid.
It was created by taking the same ttml-segment.mp4 as a source and just
duplicating the MDAT box, but without then also fixing the TRUN box. The
duplicated data was thus not referenced. The test case still worked,
because the prior code did not look at the TRUN box and the sample
specification at all and just handled any full MDAT box = 1 sample. The
testdata was replaced with a new file, which is basically the same as
for the multiple samples case, but with the two samples split into two
MDAT boxes.
2025-02-17 12:39:10 +01:00
Álvaro Velad Galván 9e71a011f2 fix: Only create TextTrack of SimpleTextDisplayer when necessary (#7913)
Fixes https://github.com/shaka-project/shaka-player/issues/7912
2025-01-21 11:09:26 +01:00
Wojciech Tyczyński 6e55a3b21b build: Forbid using dot in generic types (#7904)
Fixes #2643

Happy reviewing!
2025-01-20 09:39:51 +01:00
Álvaro Velad Galván fd78ec41f5 fix: Remove useless deprecation in UITextDisplayer and add some guards in SimpleTextDisplayer (#7805)
Fixes https://github.com/shaka-project/shaka-player/issues/7803
2024-12-24 13:02:34 +01:00
Wojciech Tyczyński 51765e9693 build: Change spellchecking tool and fix spelling mistakes (#7765)
Fixes #7693
2024-12-20 12:27:05 +01:00
David HM Morgan fdf68d1994 fix(TTML): Fix absence of conversion of alpha (transparency) from 0-255 -> 0-1 (#7280)
Fixes #7279
2024-09-10 15:50:46 +02:00
Álvaro Velad Galván 0708379bad fix(WebVTT): Re-add rollover logic (#7104)
Fixes: https://github.com/shaka-project/shaka-player/issues/6448

Revert https://github.com/shaka-project/shaka-player/commit/9ab54d1485564065e02136b538b080186a0161e9
2024-07-26 04:16:50 -07:00
Álvaro Velad Galván 22a7c497b0 fix(WebVTT): Fix rendering of WebVTT in UITextDisplayer (#7023)
Fix rendering of align:start and align:end in UITextDisplayer
Fix rendering of position in UITextDisplayer

Fixes https://github.com/shaka-project/shaka-player/issues/4486
2024-07-22 15:28:34 +02:00
Wojciech Tyczyński 4f9264637d chore: Add native cue to shaka cue mapping (#7038)
Needed for #6985
2024-07-15 10:14:35 +02:00
Álvaro Velad Galván ca7fd6ed6a fix: Offset text regions that are out of viewport (#6986)
Fixes https://github.com/shaka-project/shaka-player/issues/3732 (we
resolve it using offset operation instead of clipping)
2024-07-08 10:43:25 +02:00
Álvaro Velad Galván 3b6229616e feat(TTML): Add support for IMSC1 (CMAF) image subtitle (#6968) 2024-07-02 21:43:54 +02:00
Álvaro Velad Galván fa9feb346f fix: Filter duplicate cues on text displayer append (#6949) 2024-07-01 20:29:01 +02:00
Álvaro Velad Galván 88431b6f3d fix(SSA): Support files with line breaks that are not necessary (#6947)
Related to https://github.com/shaka-project/shaka-player/issues/6943
2024-07-01 20:28:32 +02:00
David HM Morgan 3783ffd44b fix(TTML): Fix timing parsing when using 1dp (#6830)
Fixes #6829
2024-06-14 12:30:01 -07:00
MichaelSweden d564be8e89 fix: Make UITextDisplayer constructor backward compatible (#6532)
Keep constructor backward compatible with earlier that had two
arguments, i.e. make the new third optional for existing applications.

Fixes https://github.com/shaka-project/shaka-player/issues/6531

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2024-05-06 10:11:20 +02:00
Álvaro Velad Galván de2a2d885f feat: Add TextDisplayer config (#6477) 2024-04-24 18:15:44 +02:00
Álvaro Velad Galván 25427c764e fix(WebVTT): Fix multiline colored VTT subtitles (#6394)
Fixes https://github.com/shaka-project/shaka-player/issues/6374
2024-04-04 10:54:09 +02:00
Álvaro Velad Galván bcedec3a0a fix(TTML): Fix trim surrounding spaces with xml:space="default" (#6395)
Fixes https://github.com/shaka-project/shaka-player/issues/4974
2024-04-04 10:45:57 +02:00
Álvaro Velad Galván 286126edf1 fix(WebVTT): Remove rollover logic because we always transmux TS (#6397)
Fixes https://github.com/shaka-project/shaka-player/issues/6320
2024-04-04 10:24:37 +02:00
Joey Parrish 4ae15c2c6f refactor: Move sequence mode VTT offset calculations (#6332)
This moves VTT sequence mode offset calculations into a method.

It also makes all X-TIMESTAMP-MAP usage dependent on HLS specifically,
rather than sequence mode, simplifying the conditions. Sequence mode is
typically only used with HLS, and X-TIMESTAMP-MAP is explicitly only for
HLS. So excluding X-TIMESTAMP-MAP for DASH makes sense, instead of
conflating HLS and sequence mode.

This required updating some tests to explicitly set both the manifest
type and sequence mode flag.

This does *not* change the offset calculations themselves. Changes will
be made in follow-up PRs.

Issue #6320
2024-03-06 16:36:43 -08:00
Wojciech Tyczyński d0e64d7379 fix(VTT): fix setting textShadow when multiple CSS classes provided (#6287) 2024-02-26 08:16:05 +01:00
theodab 03633e47bb feat(text): Add time context to modifyCueCallback (#6252) 2024-02-20 00:37:33 -08:00
Dave Nicholas 335eab08ba feat(WebVTT): Handle badly formed VTT (#6147)
Handle remove chevrons that appear as part of the inner text of the
element to avoid parse failure.
2024-01-26 13:01:51 +01:00
theodab bd944d15db feat(text): Add MediaSource.modifyCueCallback (#6167)
This callback gives developers a chance to modify cues after they are
parsed but before they are appended.
2024-01-25 23:36:48 -08:00
Dave Nicholas ee600c4fd5 feat(WebVTT): Remove un-needed VTT payload normalisation (#6145)
The tXml parser gracefully handles this now, so it is no longer needed.
2024-01-23 16:53:50 +01:00
Álvaro Velad Galván 2862228716 fix(TTML): Clip to video when extent is not present (#6086)
Fixes https://github.com/shaka-project/shaka-player/issues/4793
2024-01-11 18:24:05 +01:00
Antonio Díaz Correa 42c235d123 fix: avoid uiTextDisplayer.destroy crashing if called more than once (#6022) 2024-01-08 09:40:12 +01:00
Álvaro Velad Galván 68903e130e fix: Fix color detection in text utils (#5970) 2023-12-02 08:43:14 +01:00