Commit Graph

3054 Commits

Author SHA1 Message Date
Jacob Trimble fda12e770d Update changelog and bump versions for v2.5.3
Change-Id: I49b3ac8ae1ded909f3324a9089416357cdc46c63
v2.5.3-master
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
Theodore Abshire edc77647ea Made shakaDemo namespace for demo.
Change-Id: I53508d808f9b1d868f4c797095dcc9829cac7871
2019-06-28 10:50:19 -07:00
Sandra Lokshina a4a2ef5a7c Make the demo close button implement shaka.ui.Element
Issue #2011

Change-Id: I51c828b0457133ccee4b3f3ff2e1a33da8b3a34c
2019-06-28 09:42:11 -07:00
Theodore Abshire 9ce78fe388 Convert demo to goog.require and goog.provide.
Previously, in uncompiled mode, we were loading Shaka Player using
goog.require calls, but loading the demo code directly. This meant that
the demo code was loaded before the Shaka Player, code, which lead to
issues if something needed the "shaka" namespace to exist during
load-time; for example, if a demo class wanted to extend a Shaka class.
This adds goog.provide calls to the demo, so that it can be loaded with
goog.require also while in uncompiled mode.

Change-Id: If6cc92db0ce05dd9c3f298e9bd1a5119452ad8a4
2019-06-27 22:02:36 +00: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
Jacob Trimble 83de1ad634 Use toBe instead of toEqual for primitives.
This ensures that we get the expected types and that type coercion
doesn't convert between types.  This also ensures we are consistent
in how we check for equality of primitives in tests.

Change-Id: I9f3aacdf25ab1afe5e8d6e4b895b5299ee687d54
2019-06-26 18:57:18 +00:00
Jacob Trimble 010a60b8f1 Use objectContaining in text tests.
Instead of checking each property separately, just use
jasmine.objectContaining.  This also adds a utility for matching a
number that is close to an expected value.  This is required when
matching objects with toEqual().

Change-Id: I4de49cfaf254e0752beffc97c578a77f9ec8ee95
2019-06-26 18:54:13 +00:00
Jacob Trimble b235ca4fe7 Favor expect.not.toHaveBeenCalled.
Change-Id: I7009ff69bfca5ef8a38bcdff73a16a02cfa205b1
2019-06-26 18:53:00 +00:00
Jacob Trimble e2ba179201 Favor using toHaveBeenCalledTimes.
This gives better error messages than using toBe() or toEqual() with
the number of calls.

Change-Id: Ice353f1ebcc715da69416da2d983e919597f82d1
2019-06-26 18:52:36 +00:00
Jacob Trimble 2d4904cb75 Add tests for errors during clear buffer.
This error wasn't caught before, but was fixed in a recent CL.  This
adds a test to ensure we don't regress later.

Change-Id: I10e72303c39de82bb9a1f7cb4a6b171c46fdbecd
2019-06-26 17:50:01 +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
Sandra Lokshina aa259565fe Reflect code changes in ui tutorial.
The seekbar color consts got moved from Controls
to ui.Constants.

Issue #2005.

Change-Id: Id8c09cb59930f2f23a350cb1e7be3c8708c121d7
2019-06-21 11:21:07 -07: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
Jacob Trimble 5aed799cb9 Avoid PromiseMock in DASH live tests.
This converts them to be normal async tests instead of mocking the
clock and Promises.  This uses some internals on the DASH parser for
updates to allow the tests to complete quickly.

Issue #1379
Issue #1953

Change-Id: I6d21d124a290920e568b8a275221140e1b27941b
2019-06-19 20:30:43 +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
Jacob Trimble ac2df7c12a Error if trying to exclude unselected browser.
This ensures you spell the browsers correctly when excluding browsers
instead of silently ignoring badly spelled browsers.

Change-Id: I039c4a418f0e716d54daa195588890f37af3bb7a
2019-06-18 22:53:42 +00:00
Theodore Abshire c468730e19 Fix build script for receiver app.
The previous fix only fixed uncompiled mode, it turns out.
The actual root problem was a namespace collision in the build
script for the receiver app, which lead to the player namespace
being over-ridden by just debug/log.js.
This fixes the build script to just not include debug/log.js. The
receiver app wasn't using that file anyway.

Change-Id: I290a6a9051c86c816614afe3922d2c82bf8cbfa5
2019-06-14 16:19:06 -07: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 98b8d55575 Workaround error in promise-polyfill.
A recent push to promise-polyfill (used by our promise-mock) caused
errors in our tests.  This blacklists the new release until they
release a fix.

See taylorhakes/promise-polyfill#103

Change-Id: I65784e393143a21769c0a40e3f8b93cf189f7e8d
2019-06-14 12:00:16 -07:00
Theodore Abshire 0fa00ddf62 Remove assert on demo assets.
There was a fairly unimportant assert on demo assets that was, for
whatever reason, causing problems on Chromecast.
Specifically, assets are created very early in the load process, early
enough that the asserts module might not have been loaded yet.
Normally goog.require would ensure that is not a problem, but it does
not seem to be helping.
In any case, this just removes that assert.

Change-Id: I9d3bfcdb4fc87df0dec2b167eaef768df6f81d89
2019-06-13 22:07:46 +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
Jacob Trimble 0cebfe649c Rebuild for changes in build scripts.
Now if the build scripts change, the auto-detection for changed files
will force the library to be rebuilt.  This allows detecting changes to
the build script when determining if there are changes.

Change-Id: Ibf4fc3fb2197ae5993c9acd7adb65c88e205b6f4
2019-06-11 22:37:06 +00:00
Jacob Trimble 12b5cee024 Fix some python3 compatibility.
Change-Id: Iab859ba529f1339cec8befc2fbce46ca28a62a0f
2019-06-11 22:36:18 +00:00
Sandra Lokshina 0e317d64e0 Add tests for UI reconfiguration.
Change-Id: I695b8bd18a42db74fe3adb45b31aae2579448310
2019-06-11 22:20:13 +00:00
Joey Parrish f8cab5df55 Clean up code-folding comments in assets.js
One of the ending comments seems to have gone away during a refactor.
This adds it back, and cleans up all the blocks with useful comments.

Change-Id: I29d093255805d806bb9957896ed348b0fdf8649e
2019-06-11 20:01:43 +00:00
Joey Parrish c7ed9d769a Update docs WRT default output name from build scripts
Closes #1929

Change-Id: Ie3a15ba3928ca21f9f4eb5c8ff423e2b5875782c
2019-06-11 19:44:52 +00: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 d438e03e32 Remove old alias in docs script.
Change-Id: I58c8efbe634f26b475b1e964d189dbe787a7aca5
2019-06-11 10:33:37 -07: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
Jacob Trimble 8130e7ca42 Refactor StatusPromise use in MSE test.
The StatusPromise isn't needed when just checking for resolve/reject;
we can use await or expectAsync for that.  So this removes the usages
of StatusPromise that only check for resolve/reject.

This also renames the destroy() variables to "d" to make them different
from the operational promises.

Change-Id: I48e807d84e56ee28b7489c572570e11e6325a4ed
2019-06-10 22:25:51 +00:00
Michelle Zhuo f8f384902e Convert MediaSourceEngine to ES6
Issue #1157

Change-Id: Id9757ac39c37a149630c87bceacb11cdd2144f04
v2.5.2-master
2019-06-10 22:19:14 +00:00
Jacob Trimble f3f427eb0b Disallow naming variables "async".
Fixes #1588

Change-Id: I2e1fc04a18d3f52e4fc46aa7b7b558989d5bced2
2019-06-10 21:56:19 +00:00
Sandra Lokshina 1f8dabc2e1 UI tests refactoring
This change splits ui tests into general tests and customization.
This is a base for adding more customization tests and creating a
suit for a11y tests.

Change-Id: Icd293ac382ec4a14e15b5be57bf194f83e45f89d
2019-06-10 21:55:52 +00:00
Sandra Lokshina 4bb1207ee3 Update UI tutorial according to the CWIP feedback.
Fixes #1954

Change-Id: I89166832b174df6e4db9c8f153b3edd0962319ef
2019-06-10 21:54:20 +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
Theodore Abshire b805d15444 Convert externs to ES6.
Issue #1157

Change-Id: Ib8ddecc7106fea8c24c10cfac406c4709a3f275b
2019-06-10 17:52:08 +00:00
Jacob Trimble 94a47ec61f Add a generic test filter.
This add a filterDescribe that can be used to filter groups of tests
based on platform support.  This consolidates the different test
filtering to one place.

Change-Id: I8f320fcf0edfa2d984433890fcfc3714e78b195b
2019-06-07 18:56:38 +00:00