Commit Graph

59 Commits

Author SHA1 Message Date
Álvaro Velad Galván 55b0681151 feat: Add getMimeType method to shaka.Player (#9592) 2026-01-22 14:28: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 cad470cdc5 fix: Support use addTextTrackAsync with NativeTextDisplayer (#9122) 2025-09-22 13:29:04 +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 ba56bae473 feat: Add getChaptersAsync method (#8541)
This allows the segmentIndex to be created if it is not already created
and also allows operation with CastProxy.
2025-05-06 07:55:53 +02:00
Álvaro Velad Galván c312bd6186 feat: Allow acquire thumbnails without track ID (#8129) 2025-02-20 14:35:30 +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
Wojciech Tyczyński 445b0ce67f feat: Use source tags instead of src attribute (#7406)
Needed for #5022 

This PR does not enable AirPlay on MSE yet, but moves shaka from using
`src` attribute to `source` tags. With this change we will be able to
enable it more easily, as `src` and `source` should not be used
together.
2024-10-15 12:47:10 +02:00
Álvaro Velad Galván 3a146c2ee6 fix: Fix external image track mime type (#7333) 2024-09-18 08:02:44 +02:00
Álvaro Velad Galván 7cf332e3a9 fix: Apply playRange config to src= (#7168)
Fixes https://github.com/shaka-project/shaka-player/issues/7135
2024-08-20 09:38:57 +02:00
Álvaro Velad Galván fc1e72c1dd test: Fix flaky test in Edge macOS (#6930) 2024-06-28 08:19:16 +02:00
Álvaro Velad Galván 8232c600ce fix: Re-add setting playbackRate to 0 to control buffering state (#6546)
Fixes https://github.com/shaka-project/shaka-player/issues/6527
Fixes https://github.com/shaka-project/shaka-player/issues/6355
This reverts commit
https://github.com/shaka-project/shaka-player/commit/6156dced6bddc5e2cd0cc52071295cff63cadfcd.
2024-05-08 11:16:40 +02:00
Joey Parrish 0263386599 test: Fix several test failures (#6281)
- Fix bogus assertion failure in tests on Safari (#6272)
- This test should not be seeking so close to the duration (10ms) as to
cause flakiness on certain browsers. Adjusting the seek time fixes the
assertion without compromising the purpose of the test.
 - Fix uncaught rejections in load graph tests (#6274)
- These tests had calls that were interrupted by the teardown process
that occurs after the test body. Waiting for the operations before
ending the test fixes the issue.
 - Fix interrupted load in test on Tizen (#6274)
- This test triggers a deliberate DRM error without waiting for load().
On most platforms in the lab, the load() operation completed before the
error. Not so on Tizen. This exposed a general problem in which we
should be catching errors in this test. Only timing saved us on most
platforms.

Closes #6272
Closes #6274
2024-02-22 10:27:35 -08:00
theodab 4425dca283 chore: Remove state engine (#5752)
The state engine mechanism, designed for the player class, was
over-engineered. The structure of the class makes debugging player
errors unnecessarily annoying, by obfuscating the code-path the error
followed, and in general
has created a significant amount of technical debt.
This changes the player to use an async-await setup for the top-level
operations, laying things out much more cleanly
and linearly.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
2023-10-30 23:59:08 -07:00
Álvaro Velad Galván 88e4cd4116 feat: Add thumbnails support in src= (#5802)
Closes https://github.com/shaka-project/shaka-player/issues/5778
2023-10-26 07:54:17 +02:00
Álvaro Velad Galván 6156dced6b feat: Stop setting playbackRate to 0 to control buffering state (#5696)
Closes https://github.com/shaka-project/shaka-player/issues/2093
2023-10-05 08:38:29 +02:00
Joey Parrish ffafacfb84 test: Disable power-saving features on both Chrome and Edge (#5508)
Power-saving features on Chrome and Edge were subtly interfering with
playback tests. Timers could be throttled, and both video-only media and
media in occluded windows could be paused by the browser.

This was discovered only after awaiting play() Promises in all tests.
These Promises were being rejected with useful error messages that led
to these discoveries.

Awaiting play() requires us to disable stall detection during playback
tests. This is because on some platforms, stalls get resolved by calling
pause() and then play(), which would cause the original awaited play()
Promise to be rejected.

Finally, some Player tests created additional Player instances that were
unnecessary. Removing those allowed me to centralize most of the
configuration to disable stall detection.
2023-08-18 18:45:05 -07:00
Joey Parrish 6b56ed7440 test: Fix Tizen src= test (#4452)
The test to show that src= playbacks can log width/height data was
failing on Tizen.  This is because Tizen was ignoring the SAR (sample
aspect ratio) and showing the content at 256 pixels wide, whereas
other platforms were displaying at 258 pixels wide.  The point of the
test was never to check a platform's support for SAR, so the video has
been re-encoded to display consistently across platforms.

This issue began when the test was added in PR #4435.

The video file is now also much smaller than it was before (from 177kB
to 37kB).

Re-encoding was done with:

```sh
ffmpeg \
  -i test/test/assets/small.mp4.orig \
  -c:v h264 -vf setsar=1:1 -crf 51 \
  -c:a aac -b:a 16k \
  -y test/test/assets/small.mp4
```
2022-08-30 07:57:47 -07:00
Álvaro Velad Galván 9bbfb57cb4 fix: return width and height in the stats when we are using src= (#4435)
related to https://github.com/shaka-project/shaka-player/issues/4434
2022-08-25 14:23:38 -07:00
Joey Parrish 80e81f1391 fix: Wait for chapters track to be loaded (#4228)
addChaptersTrack() was already an async method, but it did not wait
for the chapter data to be loaded by the browser.  The solution is to
wait for the `load` event on the `<track>` element we create.

To accomplish this, some cleanup and refactoring was done in how
tracks are managed.  Summary of changes:

 - The `addtrack` event, which triggered management of tracks in src=
   playback, is now used for all types of playback.  In src= mode, it
   manages all tracks, and in MSE mode, it only manages chapters
   tracks (which are added to the video element as in src= mode).
 - `processChaptersTrack_()` has been renamed to
   `activateChaptersTrack_()`, since its only job is to set the
   track's mode field to make the browser load it.
 - `activateChaptersTrack_()` is now only ever called via the
   `addtrack` event.
 - `activateChaptersTrack_()` no longer loops over all chapter tracks
   on a timer, and instead only touches the single track it was
   called for.
 - `addSrcTrackElement_()` now returns the HTML `<track>` element it
   creates.
 - `addChaptersTrack()` now awaits a `load` or `error` event to
   complete (or fail) the operation.
 - Existing tests for addChaptersTrack had long delays to work around
   this issue; these delays have simply been removed.

Fixes #4186
2022-05-16 16:10:44 -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
Álvaro Velad Galván 8c626aec23 fix: Support multiple chapter tracks with same language (#3868)
Issue #3597
2022-01-18 10:02:12 -08:00
Álvaro Velad Galván 160e36be46 feat: Add chapters support (#2972)
Add the following methods:
 - addChaptersTrack
 - getChapters
 - getChaptersTracks

The following formats are supported: WebVTT and SRT
2021-06-22 14:50:09 -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 faa1e52902 feat(text): Add addTextTrackAsync (#2932)
This new method can make a HEAD request to the server to determine the MIME type.  The old method (addTextTrack) is now deprecated and will be removed in v4.
2020-10-22 09:32:06 -07:00
Theodore Abshire 98df64c1af Feat(player): Add label to LanguageRole externs
Closes #2904

Change-Id: I96dffaf377f856db9a14d9784d3bbbbb08c297b8
2020-10-14 20:30:10 +00:00
michellezhuo 648e12e9c1 build: add goog.require for compiler upgrade (Part 4)
Change-Id: I6b4a7209c7a3a9f6069351377dac32f22222c0fb
2020-10-12 16:54:08 +00:00
Michelle Zhuo 093103e646 build: test util refactor for compiler upgrade
Refactor the test util and relevant files for compiler upgrade.
In test files, a few files depending on each other formed a
dependency loop.
For example, test/Util has a few methods for waiting/delay that
uses Waiter, and those methods should be in Waiter.
This changes helps to break the dependency loop, and helps to
unblock the compiler upgrade.

Change-Id: Ie5ece145748bf2eafe3fa065b79cf2a81b1637e1
2020-10-09 22:49:11 +00:00
Álvaro Velad Galván 4659a97c8b feat(text): Add support to side-load subtitles in src mode (#2874)
This uses the HTML5 Track element to support side-loading of WebVTT.
2020-10-01 09:53:17 -07:00
Joey Parrish 7e6a0f38ff fix: Correct license headers in misc. files
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs.  This does not
affect the compiled output, and is only done for consistency.

Issue #2638

Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
2020-06-09 16:13:56 -07:00
Joey Parrish 3bf5ed10b7 Fix flaky test results on Chromecast
One of the src= playback tests was failing on Chromecast with an
estimated rate of about 20% when the src= tests are run alone.  The
timeout for playback to start was found to be too short on that
resource-limited embedded device.  This increases the playback timeout
in the test.

Fixes: 157702575

Change-Id: Ib8d5a0d961bc0e99e77c16b93ca63569f3a2cc31
2020-06-08 18:00:22 +00:00
Joey Parrish 21c3d7dc4d Fix language preferences in src= mode
Changes to the load() promise resolution on iOS for #2483 accidentally
broke language preferences in src= mode, and the regression test for
this revealed subtleties in how and when tracks may be selected with
Apple's native HLS.

By waiting for a "change" event on video.textTracks, we can make sure
Apple is ready to accept our own text track selection.

This should now work correctly on all platforms.

Closes #2593

Change-Id: Iec59b89001fbec3779a0f7087ce11efe1be003ef
2020-05-28 10:02:50 -07:00
Joey Parrish af206b79db Fix src= test failures
These issues were mostly introduced in "Don't preload data on iOS",
and were not detectable in Chrome.  They came up during a full test
pass in our test lab on all browsers.

Change-Id: Ife6e157a18df84ea30b840615f6d06a22e340a44
2020-05-21 18:42:01 -07:00
Joey Parrish 6b11f1ecdc Don't preload data on iOS
Instead of calling video.load() and waiting for loadeddata for src=,
wait for loadedmetadata.  This should be a safe event to use in most
cases, and calling video.load() causes native HLS to start preloading
an uncontrollable amount of content.

The exception is if the app sets preload='none' on the video element.
If this happens, we will detect it, log a warning, and avoid the
loadedmetadata event which may never fire.  This is not a scenario we
will officially support, but at least we can prevent a hang in
player.load().

Closes #2483

Change-Id: Id64c8f23cb8fa82bb5c301abafb51f2d9d8730f7
2020-05-21 20:01:32 +00:00
michellezhuo dc32bd88ba Remove extra text track generated by SimpleTextDisplayer in src= mode
When SimpleTextDisplayer is constructed, a TextTrack is created,
and that cannot be removed. This introduces an extra TextTrack when the
content is played in src= mode.

This is the straight-forward solution to filter the extra TextTrack out
by the label in src= mode.

Issue #2516

Change-Id: I8c417f837e4ad2f90ec779b533c8484de9e22b11
2020-05-01 16:48:04 +00:00
Joey Parrish 11f3347a48 Fix static method aliases
We used to alias static utility methods by assigning the method itself
to a local variable.  This is not allowed by the new Closure Compiler
release that we are adopting, and for good reason.

The old compiler did not understand the use of "this" in static
methods, but the new one does.  And it turns out that when we start
using "this" in static methods (see #2532), aliasing the method itself
can break everything.

When you refer to "this" in a static method, it refers to the class.
This is really useful in utility classes that have private static
methods they use to perform common tasks.  However, just as it ruins
the value of "this" to alias an instance method, the same is true of
an ES6 class's static method.

The fix is to always alias the class instead of the method.  The new
compiler will simply not let us get away with the old way any more, so
regressions after this are unlikely.

Issue #2528 (compiler upgrade)
Issue #2532 (static "this")

Change-Id: Id800d466e639c7cbcf4aa6fbb05114c772a2229f
2020-04-30 19:28:53 +00:00
Joey Parrish db42d7e436 Revert "Fix bogus text track in UI with src= mode"
This partially reverts commit ad3d4604, because that fix seems to have
caused #2523.

This also adds a regression test for #2523.

Reopens #2516
Closes #2523

Change-Id: If3ed5942fff029f522e24048edcb4a04e7cc30e9
2020-04-23 21:33:28 +00:00
Joey Parrish ad3d4604af Fix bogus text track in UI with src= mode
When the non-UI TextDisplayer is constructed, it creates an extra
TextTrack that can never be removed.  This leads to a bogus text track
showing up in the UI when content is played in src= mode.

This changes the TextDisplayer to disable the extra TextTrack (since
there is no API to remove it) and changes the Player to ignore
disabled TextTracks when generating a track list for src= playbacks.

Closes #2516

Change-Id: I2e651f737445049da5fa46a798a2bc0751de2822
2020-04-21 13:26:14 -07:00
Joey Parrish b2c4ef5cf3 Fix flaky src= integration test on IE/Edge
For some reason, on Edge and IE, starting this particular piece of
content at time 5 results in playback beginning at 4.9.  It could be
that the number is rounded to a keyframe or something.

This changes the test to expect the start time to be within 200ms of
the requested start time.

Change-Id: I5399a1eaf8a84b57a88359db2584f043e4a11e81
2020-04-10 17:59:44 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
Joey Parrish 94f07dd410 Fix ratechange events w/ src= playback
The Player ratechange event is a filtered version of the video
ratechange event.  This is necessary because we manipulate
playbackRate as part of our buffering state management.

The UI uses this Player ratechange event to drive the playback rate UI
menu, but the event was not firing for src= playbacks (native HLS or
plain MP4s).

This fixes the ratechange event for src= playbacks, and also fixes a
small mistake in the MediaSource setup that could have resulted in the
ratechange event being triggered before playRateController_ was
created.

Closes #2488

Change-Id: If85e489d681cfbb1ae6141b490d82264e1d932bd
2020-04-07 23:36:07 +00:00
Theodore Abshire 6a6a47c5ca Added stats for time taken in load stages.
Change-Id: I3b9c8397999468e606b241f160174a2063b23ae0
2020-01-29 18:57:45 +00:00
Jacob Trimble 011749e95f Standardize argument comments.
This changes the eslint rule to enforce a strict pattern for the
argument comments.  The comment must appear before the argument and
must be /* foo= */.  This still ignores line comments.

Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
2020-01-06 19:40:52 +00:00
Joey Parrish a48f8792a9 Move test-only method to test utils
This method should probably never have been in the library, since it
creates a fixed-sized, muted element.

Change-Id: I53b474305465bef34d43ce40ec5e7dedceb20a25
2020-01-06 18:57:28 +00:00
Álvaro Velad Galván 5411838f7c Add startTime support in src= mode (#2271)
Closes #2267
2020-01-03 13:45:53 -08:00
Joey Parrish 64896d70b0 Use shorter license header
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.

This also updates the company name from "Google, Inc" to "Google LLC".

Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
2019-11-22 18:18:36 +00:00
Jacob Trimble 52522c7dca Fix cases where errors weren't propagated.
This propagates errors in several places and fixes waiting for some
async calls.

Change-Id: Idf4519b473538c1fa00bfe63e634194610ba29f2
2019-06-19 20:35:30 +00:00
Jacob Trimble 799e96c05c Convert test utils to ES6.
This also removes the unused SimpleIDB type and removes the duplicate
code in Utils that appears in Waiter.

Issue #1157

Change-Id: Ib3cfc16212b9d169b360825a25a084c5ebd7b80f
2019-06-03 18:41:17 +00:00
Jacob Trimble e59187adf5 Convert player tests to ES6.
Issue #1157

Change-Id: Ib405576ff77e324e5586b93cdbfddcde69d264ab
2019-05-22 16:14:19 +00:00
Jacob Trimble f225c047f6 Reorder eslint rules and add some more.
This reorders the rules so they mostly are ordered the same as the
eslint documentation.  The exception is the few at the top, most of
which should be removed.  This also removes some rules that appear in
the recommended or the Google set.  Lastly this adds some more rules:

- Require parenthesis when using "new".
- Disallow confusing regex (e.g. /=/).
- Disallow some confusing coercions (e.g. +foo).
- Disallow some Unicode characters in a regex.
- Disallow using "async" in a Promise constructor.

Change-Id: I597b472bdaee5b4cb92354f057e7ae6aeb96eefa
2019-05-09 22:14:18 +00:00