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
This fixes a TODO and fixes setting the "active" track when switching
languages when not displaying text.
Fixes#2010
Change-Id: Ic4cf4126ffb9b93a09af998e20f9da0e7af852fb
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
This enables custom buttons that aren't part of the
library to be used in compiled mode.
Closes#2011
Change-Id: I500f93a86bfd2893948e594a969b6f8208836251
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
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
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
We can calculate the index of the highest bit set using log() instead
of looping and using bit math.
Change-Id: I6ff9af600cb17ea83398ce6fbbcb84982a789653
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
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
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#1985Closes#1994
Change-Id: Ibe45902b659516ae66bd7da33007fd15e7f64207
- 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
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#r33913938Closes#1989
Change-Id: I97bff23faae897e08fc270a7aa694ddf48076080
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
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
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
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
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
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
"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
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
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