Commit Graph

1883 Commits

Author SHA1 Message Date
Jacob Trimble fda12e770d Update changelog and bump versions for v2.5.3
Change-Id: I49b3ac8ae1ded909f3324a9089416357cdc46c63
2019-07-03 08:40:27 -07:00
Theodore Abshire fe7f42105f Fix presentationDelay being set to NaN.
In the DASH parser, if there was no suggestedPresentationDelay and
ignoreMinBufferTime was set to true, the parser would set the
presentationDelay to NaN. This was because Math.max() will return NaN
if undefined is passed into it.
This changes minBufferTime to default to 0, if ignoreMinBufferTime is
true.

Fixes #2015

Change-Id: I8fc61706a04d14fd729e2185ce993a8bc87e48e5
2019-07-01 11:53:30 -07:00
Jacob Trimble 28cc9f6f9d Favor includes over indexOf.
Change-Id: I78a8334c025fe11d485cb2f9cb7cb4cb7dcb6c2c
2019-06-27 11:54:11 -07:00
Jacob Trimble a27f50dd43 Avoid changing variant when switching text lang.
This fixes a TODO and fixes setting the "active" track when switching
languages when not displaying text.

Fixes #2010

Change-Id: Ic4cf4126ffb9b93a09af998e20f9da0e7af852fb
2019-06-27 18:40:28 +00:00
Jacob Trimble 47533d1173 Add an enumerable() method for loops.
This is a helper to aid in iterating over items.  This returns a list
of objects that contain:
- "item": The current value.
- "prev": The previous value in the list.
- "next": The next value in the list.
- "i": The zero-based index in the list.

Issue #1518

Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
2019-06-27 16:31:42 +00:00
Jacob Trimble 60d2f1cc82 Work around MediaSource duration bug.
Fixes #1967

Change-Id: Ie2a41cb17427316ce65cf180507c1fb1f2c6f11a
2019-06-26 20:57:30 +00:00
Michelle Zhuo 2e28a6c976 Small refactor for Hls Parser
Extracting small functions from createVariantsForTag_() to make it more
readable.

Change-Id: Id8bdb08e985d31396ef34441057de9854b8704b0
2019-06-26 16:41:16 +00:00
Sandra Lokshina 24f5a29501 Export protected memebers of shaka.ui.Element
This enables custom buttons that aren't part of the
library to be used in compiled mode.

Closes #2011

Change-Id: I500f93a86bfd2893948e594a969b6f8208836251
2019-06-25 22:07:34 +00:00
Sandra Lokshina fc3f750a66 Don't create media state for text until ready to stream.
We start streaming text once subtitles have been enabled.
With external text, we used to create a media state for it
as soon as text was added even if captions were disabled
and we did not actually stream, although no text was
being parsed and shown.
This lead to the following problem:
If external text was added with subtitles disabled, we
created the media state with no actual cues in it.
Once the subtitles were enabled, we saw that a media
state existed for text and assumed it had content.
So, we started streaming, but nothing was shown.
This change makes us only create the media state if
subtitles are enabled and defer creation otherwise.

Closes #1938.

Change-Id: Iee39c30fbd6b7f0abe7772dfb75cba561fcc9998
2019-06-25 18:54:13 +00:00
Jacob Trimble f6d0f15fa6 Refactor handling of destroy().
This changes several classes to use the Destroyer class to handle
destroy().  This also changes the behavior to not ignore destruction
and instead throw a new error.  This is more clear for callers and
ensures we propagate errors.

Change-Id: I756c085639558509c22e5c43d69ddf4acd28d46f
2019-06-19 20:39:20 +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
Sandra Lokshina d1c8eb7d5e Fix switching text on an edge case.
When switch() is called, it checks for what segment/period the media
state will need to fetch next. As text is much smaller than audio/
video, it might be the case that text has all the segments in
period i while audio and video are still in the process of fetching
them.
Thus, the next period needed for text will be i+1, while for other
media states it will be i.
Switch() assumes that if the period needed is not the same as
current period, a perios transition is about to happen and there's
no point in switching streams now since they're about to change on
the next update anyway.
However, the period transition only happenes if all the media
states require it. In our edge case, only text is ready for the
next period, so transition will not happen.
This change corrects the assumption "if a media state is ready
for the new period, don't switch" to assumption "if ALL media
states are ready for the new period, don't switch."

Issue #1774

Change-Id: I35f1b7ae10704922fb5692e02fc5f2edc6982575
2019-06-18 23:08:45 +00:00
Jacob Trimble 424f21c839 Use log2 to avoid a loop.
We can calculate the index of the highest bit set using log() instead
of looping and using bit math.

Change-Id: I6ff9af600cb17ea83398ce6fbbcb84982a789653
2019-06-18 22:54:36 +00:00
Jacob Trimble e31f4ec3c8 Fix playback rate errors on IE11.
Apparently calling play() causes the playbackRate to be set back to 1,
so we need to call play() before setting the rate.

Fixes: 135520981
Change-Id: Ibea1cbd7c0ee4605b10b0fee87a8b5c069e04fa3
2019-06-18 22:53:59 +00:00
Sandra Lokshina 684dc25e52 Fall back to fast forward by seeking on large rate values.
If a value given to player.trickPlay() is outside of what
the browsers accepts for video.playbackRate, fall back
to fast forward by seeking, same as we do for rewind.

Closes #1957.

Change-Id: I12275377b70dc1d0e2ece7f5647e6590f0304cf5
2019-06-14 21:40:11 +00:00
Sandra Lokshina e74f0b7793 Make fast forwarding work when video is paused.
Closes #1801

Change-Id: I5d835b5a80a30d6169d58dc50e096d5743933853
2019-06-14 21:04:17 +00:00
Jacob Trimble 7bbca076aa Detect the chunk size the browser supports.
Instead of using a hard-coded chunk size when creating large strings,
this now uses a browser check to detect it.  This allows us to use
large chunk sizes on browsers that support it but still support low-end
devices.

Closes #1985
Closes #1994

Change-Id: Ibe45902b659516ae66bd7da33007fd15e7f64207
2019-06-14 19:53:50 +00:00
Jacob Trimble e2fa4626b5 Decrease time it takes to run tests.
- Reduce times for "short delays".
- Remove backoff delay from networking tests.
- Avoid hard-coding delays in the library.
- Move Storage tests to integration tests since they use indexedDB (and
  take over 200ms each to run).

This reduces the time it takes to run unit tests (with --quick) from
50 seconds to about 6 seconds.  Now all but one unit test finish <100ms.

Change-Id: I88461472a87c4cf750a36d07d07422818e069a4d
2019-06-12 20:53:08 +00:00
Joey Parrish 44d5ec18b7 Fix reading customData from standard Cast LOAD message
In my previous fix, I misread the Cast SDK docs and read this field
from the wrong part of the message.  I did not (and still do not) have
any way to test this feature request from @bojant987.  My mistake was
pointed out to me in this comment:

https://github.com/google/shaka-player/commit/bc91f6c9#r33913938

Closes #1989

Change-Id: I97bff23faae897e08fc270a7aa694ddf48076080
2019-06-12 09:35:45 -07:00
Joey Parrish bc91f6c966 Fix ignored customData from standard Cast LOAD message
Closes #1989

Change-Id: Ifac4874d0fb6a8f2b3aa471a7e81357ff8361284
2019-06-11 19:41:31 +00:00
Jacob Trimble 3da809019b Enable additional ES6 linter rules.
Change-Id: I6861541b27153ba034364a5972a9b086de581cef
2019-06-11 18:35:09 +00:00
Jacob Trimble 1d33b748d8 Fix recent MediaSourceEngine test failure.
A recent refactoring caused a test failure on Chrome due to a Promise
getting rejected without a "catch" block and getting an unexpected
rejection error.  This adds the expectation first so we don't get that
error.

This also removes the empty "catch" blocks since we use async/await,
which introduces another Promise, so the "catch" block won't suppress
the unhandled rejections like we want.

Change-Id: Ib217b4b374668d800a0eeb1a9b8069269bccf261
2019-06-11 10:32:16 -07:00
Michelle Zhuo f8f384902e Convert MediaSourceEngine to ES6
Issue #1157

Change-Id: Id9757ac39c37a149630c87bceacb11cdd2144f04
2019-06-10 22:19:14 +00:00
Joey Parrish ef4117483f Update changelog and bump versions for v2.5.2
Change-Id: I3a44f84afc5fc1529566943b8626583f998027e3
2019-06-10 21:11:58 +00:00
Jacob Trimble 98aa050de9 Fix addEventListener on some platforms.
Some platforms (e.g. IE11 and Tizen) don't support passing an object as
the third argument to addEventListener.  When we do, it interprets it
as a "true" for the capture value and causes the listener to be called
at the wrong time.  This now detects whether the browser supports this
and calls the boolean version if not.

Fixes #1979

Change-Id: I05b3f5e536a9bcb5c275cac7f243a9ccc88f8149
2019-06-07 16:46:57 +00:00
Theodore Abshire 9af7baac8e Fix minor formatting issue in config utils.
Change-Id: I940cc28bf4a9a8edcf31a8ffaaa77a48e222d8f2
2019-06-06 19:56:03 +00:00
Theodore Abshire 5369d11c7b Also export PlayerConfiguration utils.
It turns out that we do not export the PlayerConfiguration utils.
This caused the recent fix to the demo configuration section to break
the nightly, when in compiled mode.

Change-Id: I361145c900f38ae132b2fa4408e0c3a7e02364ce
2019-06-06 19:55:25 +00:00
Michelle Zhuo f67df3d7ad Use eventManager.listen() instead of addEventListener in UI
Issue #1924

Change-Id: I9870d4002fd5f0f99b5de164de41b107af1b3d9b
2019-06-05 16:25:26 -07:00
Theodore Abshire f666974f8c Store base configuration in demo.
In some previous change, the drm configuration method was changed to
reset the player's configuration first, to remove any previous asset
drm configuration.
However, this also removed any user-originating configuration.
This changes the demo to store a record of the configuration from the
perspective of the user, and re-applies that instead to "reset" the
configuration.

Closes #1976

Change-Id: Ia1a659bd037cfd347e5bf763d7145e1523fca56a
2019-06-05 20:49:56 +00:00
Joey Parrish 6cb12ad174 Fix stack overflow in tests on IE
In our tests, we can load the library many times.  Each time, the
polyfills get installed, so each polyfill must be able to handle being
installed twice, and avoid any bad behavior.

The InputEvent polyfill, which is used on IE only to get correct UI
behavior on input elements, was only able to handle being installed
twice if each call was on the same copy of the library.  In our tests,
this is not the case.  If we load the library 20 times, we get the
polyfill installed 20 times.

Since it was comparing addEventListener with the polyfilled version,
this check would fail when the library was reloaded.  Each "shaka"
namespace was distinct.  So on 20 hypothetical library loads, each
polyfill would delegate to its predecessor, creating a stack some 40
functions deep.  This would trigger a stack overflow when testing on
IE.

Instead, we can store the original addEventListener in some global
place, such as on HTMLInputElement.prototype.originalAddEventListener.
If that exists, the polyfill (or some version of it) was installed, so
we don't install another.

Found in Jasmine upgrade process (issue #1949)

Change-Id: I714631c9b3ac5c59cf82a5cf7501cb544d1cb5cb
2019-06-05 09:08:37 -07:00
Theodore Abshire 1836b1693e Convert DRM engine to ES6
Issue #1157

Change-Id: I06994fa294401a008c1c2097683c3621eed438cf
2019-06-04 23:41:52 +00:00
Joey Parrish b26f674ad3 Remove non-existent field in routing payload
These inconsistencies were caught by a newer compiler.

Issue #1852

Change-Id: I2ee470f265bee726eb71ee92f442feb328c457a4
2019-06-03 21:46:39 +00:00
Sandra Lokshina 3e3e940e34 Add a temporary fix to enable casting.
Issue #1948

Change-Id: Id3953cdc32f1cdd02729c1a3f08c522b2ee376f1
2019-06-03 21:05:36 +00:00
Joey Parrish 0239d04915 Fix IE11 EME polyfill
Two patches in the IE EME polyfill became undefined during the ES6
conversion.  These mistakes were caught by a newer compiler.

setMediaKeys was declared on a different class (MediaKeySystemAccess).
And both setMediaKeys and requestMediaKeySystemAccess needed to be
declared static in order to be referenced from a static install
method.

Issue #1852

Change-Id: Ibbeb57bb3f25e84826ab094681717fdaf1b5a8b7
2019-06-03 18:40:50 +00:00
Joey Parrish 8569b1a2c7 Fix CastSender test flake
"CastSender init installs a callback if the cast API is not available"
would fail sometimes with an upgrade to Jasmine 3 (5/500 times).  The
failure had to do with the use of a global initialization callback.
It is not clear why upgrading Jasmine caused this issue to become more
apparent.

The test expected that the callback would not exist until an instance
had been created.  However, the callback, being global, might still be
around from another instance.  The callback would only be removed
after a successful initialization, so if an instance were created by
another test suite (such as the UI), and destroyed before being
initialized (a normal thing in a test environment with no cast API),
then the global callback would still exist when the CastSender tests
were run.

The best solution seems to be:
 - Decouple the global callback from any particular instance of
   CastSender, and use it to initialize any living instances of
   CastSender when invoked
 - Remove expectations on the prior existence of the global callback
   when the test begins
 - Don't rely on the global callback in the unit tests, since
   integration tests at the top level can overwrite the global
   callback when they load the compiled build

After the fix, the test passed in 500/500 complete test runs.

Change-Id: Id5f5775cf0860d5dfbd6aeb87fa11fd2f2a1297e
2019-06-03 16:53:36 +00:00
Jacob Trimble 43e798870f Misc ES6 conversions.
Issue #1157

Change-Id: Ia25a6cae84575f003980e9694b2769f2976e1342
2019-06-03 15:31:57 +00:00
Chris Fillmore d846e58af6 Add originalUri as a property on shaka.extern.Response (#1972)
This property tracks the original request uri, which would be
useful to know in the event of a redirect.

Fixes #1971
2019-06-01 13:30:41 -07:00
Joey Parrish 615ce93178 Fix formatting of test failures/errors
Code in karma-jasmine's adapter will malform test failures when the
expectation message contains a stack trace, losing the failure message
and mixing up the stack trace of the failure.  To avoid this, we
modify shaka.util.Error not to create a stack trace.  This trace is
not available in production, and there is never any need for it in the
tests.

One test expectation had to be updated.  The previous version of
jasmineError would use the original error by reference.  Now that it's
capturing a few fields explicitly, the severity value doesn't update
when NetworkingEngine modifies the original.

Change-Id: If7af93a1a0357df9763dbf6a4afc45db2c8317df
2019-05-31 21:29:27 +00:00
Jacob Trimble ab6d06320e Convert debug files to ES6.
Issue #1157

Change-Id: I11bae98bcfff812589f69f38d446e655776eadc8
2019-05-31 17:49:49 +00:00
Michelle Zhuo 8c8552ae7c Update media files to ES6
Issue #1157

Change-Id: I82213c9a20e7aa6e506732dc0295a61d2a67b1ec
2019-05-31 17:44:36 +00:00
Michelle Zhuo 7dc95710f0 Update CastSender and CastUtils to ES6
Issue #1157

Change-Id: I6d72a7cb5c8b1e4cb783d53a5465b8e4bb1b7063
2019-05-31 17:30:31 +00:00
Theodore Abshire 34e6ea4fba Convert FakeEvent and FakeEventTarget to ES6
Issue #1157

Change-Id: I027a1177fcd098f458b2cc3c3d92f93b43d26447
2019-05-30 17:11:12 +00:00
Theodore Abshire 4816359982 Convert patchedmediakeys polyfills to ES6
Issue #1157

Change-Id: I034cb3b6b947f24f828e221612f46366ec6d660d
2019-05-30 16:57:27 +00:00
Theodore Abshire 05414ff924 Finish player and cast proxy ES6 conversion.
Issue #1157

Change-Id: Ia90f6f2d9ce1659586db5d10903074bb9f141595
2019-05-30 16:55:55 +00:00
Theodore Abshire b59e4ce1a8 Make Player and CastProxy into ES6 classes.
CastProxy needs to be converted at the same time so that it can properly
adapt to the changes to Player's structure.
This only converts those classes to be ES6 classes, and does not make any
other ES6 conversions to them. That will be a follow-up CL.

Issue #1157

Change-Id: I0e0f2ce9a62639060a645969a9cc2ae6d0a400cd
2019-05-30 16:55:13 +00:00
Michelle Zhuo 0d80ea0ce5 Add some more ES6 changes in media files
Issue #1157

Change-Id: I2deb52052d08b823e5ff53ecba69b424aad78c89
2019-05-30 16:40:59 +00:00
Michelle Zhuo ebdf9d7817 Update Util files to ES6
Issue #1157

Change-Id: Ib81d198e46bc57745f60af328d1160064e253ba3
2019-05-30 16:40:49 +00:00
Theodore Abshire f584c9aab6 Convert remaining polyfills to ES6.
Issue #1157

Change-Id: Ie330cd870ccf14dc3f56987b2787970b46b1ac89
2019-05-29 23:39:08 +00:00
Jacob Trimble 848ff127f5 Add some more ES6 changes in HlsParser.
Issue #1157

Change-Id: I6869b66665a44408d678a810255096076e93bea5
2019-05-29 21:25:45 +00:00
Michelle Zhuo 3103e30d95 Convert abr files to ES6
Issue #1157

Change-Id: Iab9c4be5d98494bf644f45cc0b4a5c235b31e80e
2019-05-28 23:20:03 +00:00