Commit Graph

455 Commits

Author SHA1 Message Date
Álvaro Velad Galván 943bdb2b35 Use Network Information API to react to network changes (#2663)
Resolves #1067
2020-07-09 09:46:24 -07:00
Theodore Abshire aa9fe1d049 fix(demo): Fix behavior when UI fails to load
This modifies the demo to load localizations even when the UI fails
to load, so that the footer links will still be visible.
This also makes the footer links work in that situation, and modifies
the shaka-ui-load-failed event to return a failure reason code, so
that we can display a contextual error message in event of a failure.

Closes #2669

Change-Id: I0cf38f7e39558f1977eee490131378c32105437f
2020-06-23 23:29:37 +00:00
Joey Parrish 1ce2aa8c2a fix(demo): fix centering of MDL icons
Some icons on the demo were not centered correctly, such as the custom
content tab's "plus" button.  Some conflicting styles were changing
the line-height.

Change-Id: I08c9bb01642346b1a3b1162f779300221ae23246
2020-06-15 12:03:54 -07:00
Sandra Lokshina cda30283d2 Fix: fix UI not showing up for server side ad streams.
Apparently, IMA SDK adds their ad UI differently on SS vs
CS ad streams. The solution we devised for CS ad experience
that combined our UI with the IMA's native ad UI turned out
not to work for the SS experience - our UI was being obstructed
by the IMA's UI.
This change adds a new container for the SS IMA UI that allows
our own UI to stay visible.

Issue #2592.

Change-Id: Iedb24beeb8d6f777b1fd7f4155c591350432ec78
2020-06-12 16:55:33 +00:00
Joey Parrish f01d4edd94 fix(demo): Fix error text overflow
Some very long URLs can appear in the error text, and word wrapping is
very helpful.  This change sets styles on the element to wrap text
anywhere.

Change-Id: I9b1ddc97f90d5f1b2f5e532efd7c53f747576db5
2020-06-11 15:14:53 -07:00
Joey Parrish a7e55404ee fix(demo): Fix missing icon for demo app menu
This icon went missing in the change "Apply upstream styles for icons
font" (Change-Id: I615c1dfd86e5b9802d03050c5db0154ac196c2ef).  We may
not be using that CSS class name any more, but the MDL library still
is.  So this override that was removed needed to come back, albeit for
a different reason than before.

Change-Id: Ibf7e865604f09d9d02fe15fe9f577ea63cdf6d1d
2020-06-11 15:14:44 -07:00
Joey Parrish c1b109aabc fix: Correct license headers in CSS/LESS
This corrects/normalizes the license headers in CSS and LESS files.
The LESS tool respects the same "/*!" syntax for forcing the inclusion
of a license header, but will not dedup these licenses.  So the LESS
files generally will not use this syntax.  Instead, the build system
prepends a license header after compilation.

The exception is for our SVG spinner, which is based on third-party
CSS from codepen.  The copyright header for this is forced into the
output to give proper credit to the original author.

Issue #2638

Change-Id: I4c58e2b082f2d5e550a6f0a30feaaf9ebf82a53a
2020-06-09 16:19:38 -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 c9bd9a5dc9 fix: Correct license headers in demo app
Though not part of the library, this corrects/normalizes the license
headers in the demo app to be consistent with those in the library.

Issue #2638

Change-Id: I4546c4c6970d72ff71a37489fd582623bd6e2ca3
2020-06-09 16:07:06 -07:00
Joey Parrish d60cb13c47 fix(ui): Apply upstream styles for icons font
When we changed the font for the icons without changing the class
name, we lost upstream styles from the font server.  This was not
obvious in our demo, but was more obvious in other apps where the font
size was different.

By using the same class name as used by the font server, we get those
upstream styles applied correctly.

Issue #2633

Change-Id: I615c1dfd86e5b9802d03050c5db0154ac196c2ef
2020-06-09 19:16:23 +00:00
michellezhuo 6d373eb631 Add config for low latency mode
Issue #1525

Change-Id: I561ac50b4681036b7675efdceae70937c4b9244d
2020-06-09 17:29:54 +00:00
Joey Parrish 741424eef6 fix: Correct IMA SDK URLs in service worker and docs
The IMA SDK URLs in the service worker were http, and should have been
https.  This caused an issue when deploying v3.0.0 to appspot.

The IMA SDK URLs in the demo specified no protocol, but that is not
necessary, since https works in all contexts.

The IMA SDK URLs in the docs also specified no protocol, and one of
them was incorrect.

This corrects the mistaken URLs and makes them universally https.

Change-Id: I53dbf25ddb16ec882fcf3c070bcebed726277be1
2020-06-08 20:38:49 -07:00
Joey Parrish e6dff67b57 chore: Update receiver app ID for v3.0
Change-Id: Ied0311dcac4730eb4b72bb5404db20263993e9ba
2020-06-09 00:10:48 +00:00
Joey Parrish 0df39c62b6 Add content metadata methods to CastReceiver
This change adds the following methods on CastReceiver:
 - setContentMetadata(metadata)
 - clearContentMetadata()
 - setContentTitle(title)
 - setContentImage(imageUrl)
 - setContentArtist(artist)

These should be called from the CastReceiver's app data callback.

The title, image, and artist methods cover all the Cast content
metadata fields that have an effect in the Google Home App as of June
2020, and setContentMetadata can be used to set one of several object
formats with many more fields defined in the Cast SDK docs.

See https://developers.google.com/cast/docs/reference/messages and the
definitions of GenericMediaMetadata, MovieMediaMetadata,
TvShowMediaMetadata, and MusicTrackMediaMetadata for details.

This also uses these methods from our cast receiver demo, so our demo
will now set all possible metadata when casting our content library.

Closes #2606

Change-Id: I6386276449dbddd2501cd6e3e52206f7fb30b8fd
2020-06-04 20:59:08 +00:00
Joey Parrish aba5e2583c Rename v2.6 to v3.0 and v2.7 to v3.1
We have decided to bump the major version number instead of the minor
number, based primarily on the fact that this release breaks
compatibility with our previous manifest structure.

Change-Id: I67e4c8267c6e103cfc7278e09daac186ae5cbbc6
2020-05-29 17:50:22 +00:00
michellezhuo 7cd12770a2 Add low latency DASH and HLS Live manifest to demo assets
Issue #1525

Change-Id: Ife9855b36436d58e0f1943265c5246b661fb4e32
2020-05-26 17:28:53 +00:00
Álvaro Velad Galván 8648a3e0fc Add option to customize the polling of expiration time (#2579)
A large value effectively disables use of the expiration time

Closes #2252
2020-05-20 14:58:35 -07:00
Sergei Gridasov 2fdbd5b676 Add new option manifest.hls.useFullSegmentsForStartTime (#2575)
If true, forces HlsParser to use a full segment request for determining
start time, in case the server does not support partial requests.

Closes #2556
2020-05-19 08:24:04 -07:00
Joey Parrish df84ad838d Minor cleanup in demo/main
We had two conditionals next to each other with the same condition.
This merges them and clarifies the comments.

Change-Id: I701b30a207035c6428933c79e1b1001097701bed
2020-05-05 08:45:52 -07:00
michellezhuo 562168a1f6 Set UITextDisplayer as TextDisplayFactory in default config
In player, SimpleTextDisplayer was set as the default TextDisplayer. In
our UI, it changes the configuration to use the UITextDisplayer, and
UITextDisplayer gets constructed with the player. Later in our demo, it
resets the config, so an extra SimpleTextDisplayer gets constructed.
This introduces an extra TextTrack created by SimpleTextDisplayer.

This change sets the UITextDisplayer as the default TextDisplayer in
player's default config.

Closes #2516

Change-Id: I3f653be9fad8b2edbc2fb9de84e8abb327dcfc51
2020-05-04 20:40:18 -07:00
Joey Parrish 1076b78465 Unfork Closure base and update the compiler
The Closure Library's base.js, the Closure Compiler, and the Closure
deps-writer are all now loaded via NPM instead of commiting them
directly to the repo.  This also updates both the library and compiler
to the latest version: 20200406.

We still have a fork of the Closure Library's URI parser.  The latest
upstream version of that has too many dependencies on the rest of the
library to import directly from NPM.

Some internals of the build system have been refactored, and the
"complete" set of files in the build system now includes third_party.

Our forked URI parser does not pass lint checks yet, so the linter
does not run over third_party yet.

A couple of overly-severe sets of compiler checks have been disabled,
since even the latest Closure Library's base.js doesn't pass them.

The script-loader in load.js had to be updated for compatibility with
the new Closure Library.  If you don't return "true" now, Closure's
base.js will stop loading subsequent source files.

Some local externs that we had written are now available from the
compiler, so our local copies have been deleted.

A few type-related changes have been made as well, removing casts that
were necessary with the old compiler, but not necessary with the new
one.

Finally, this corrects some type issues in the tests using the new
"typeof" annotation from the compiler.  This allows us to type a
variable as a class defined elsewhere.  For example, after loading the
compiled library, we can reference compiledShaka.Player, which has the
type "typeof shaka.Player".  The compiler can then type-check all uses
of it in the tests.

Closes #2528 (bad polyfill code generated by the old compiler)

Change-Id: I62ec61e82d4edf342b2c576c2d4f89f11562ee65
2020-04-30 19:32:30 -07:00
Joey Parrish f15f371d20 Fix issues with nullability of strings
Various issues with the nullability of string types led to various
fixes, including:
  - adding an assertion or runtime check that something is not null
  - moving an existing null check to before a calculation
  - converting a test expectation into an assertion that the compiler
    understands (which will still fail the test if the assertion
    fails)

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I11da091c9e7974c8bea84b3b584cbd29d1e320e2
2020-04-29 22:40:49 +00:00
Joey Parrish ccb547ce50 Fix bad assertion
In "Fix missing or bad type info" (Change-Id
I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5), I added a bad assertion
that failed at runtime.  The placement was wrong and the type I was
asserting was too strict.  This fixes both mistakes.

Issue #2528

Change-Id: I297f8c846bf13775a4a59fd43349c96cfcaf3729
2020-04-29 20:32:14 +00:00
Joey Parrish f2f433887f Use square brackets for receiver app on window
The receiver app is attached to the window so it can be debugged.
This should use square brackets, since "receiver" is not defined on
"window".

Issue #2528

Change-Id: I8e725bb8292cdcb88ffccd3bc65d6d54181affa6
2020-04-29 02:31:18 +00:00
Joey Parrish 0e613e76d1 Do not abuse demo error link to carry severity
The error display in the demo app contains a link to the documentation
for a given error code.  We were previously abusing that object to
hold the error severity, as well.  This should be stored separately in
its own member variable.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: Ie7fede5fba72e2d28d201dc3e7437eafa87dc38a
2020-04-29 02:31:11 +00:00
Joey Parrish 518a3ea0a6 Fix demo usage of Storage API
The Storage API just changed to return an AbortableOperation instead
of a Promise.  The demo did not adopt this new API at the same time.

The runtime backward compatibility provided by the Storage API was
working, so the demo was not broken.  But we should be using the API
as defined.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I2d427ffb0400739c5d2de17a06c5fd79de3d39b2
2020-04-29 02:31:06 +00:00
Joey Parrish 53242f9308 Work around lack of error event type info in demo
The demo listens for shaka.Player.ErrorEvent, but it doesn't have type
information for that type.  This is because the type is defined only
in the docs, and not in the externs.  There is no actual class defined
for the event types.

The extern generator should be improved to handle this, but in the
meantime, we will use square brackets.

This was caught by a compiler upgrade.

Issue #2528

Change-Id: I55fc5fcc7f391f3155c1edc712064c5091fa363e
2020-04-29 02:30:59 +00:00
Joey Parrish 07335d79f6 Fix missing or bad type info
In many places, the implicit type info was insufficient.  For example,
document.createElement returns Element, but the actual return is
always a subclass of Element.  In many cases, we need the compiler to
know that a specific subclass is in use, so that it can correctly
check our use of subclass-specific properties.  Another common pattern
is confusion between Node and Element (which is a subclass of Node).

Almost all of the changes in the demo and UI are Element-related.

In some places, we referred to HTMLMediaElement, used in the Player
API, instead of the more specific HTMLVideoElement in use in our demo.
Since the demo uses video-specific properties, we must use the more
specific type.

Another case is the use of document.createEvent, which returns Event
according to the compiler, but in reality always returns a subclass,
like CustomEvent.

In one case in NetworkingEngine, correcting the type of an
AbortableOperation led to the discovery that we had been incorrectly
accessing a private method of that type.

In goog.Uri, there were several instances of "*" for a type, which the
newer compiler won't accept.  These have all been corrected.

Finally, in some places, we had the wrong nullability on a type.

These were all caught by a compiler upgrade.

Issue #2528

Change-Id: I7f2d070e3da32fe9ff5f444315649f3cbdb5a4a5
2020-04-28 16:51:20 -07:00
Sandra Lokshina 8cb5001984 Replace our skip button with the IMA's default one.
According to the agreement with the IMA team, we will
no longer hide their UI during ads. Instead we will
incorporate their elements into our layout.
(Some of the elements they expose are legally required
or business critical for partners for certain types of
ads).
This change replaces our skip button with the IMA one
and tweaks our layout to make it fit better.
We are keeping our ad counter and the 'Ad X of Y'
element.
Our skip button will stay in the library, and we will
use it for other (non IMA) ad integrations.

Change-Id: I648c6c65a34607685a409a264c2a03d74cc4d461
2020-04-22 21:03:11 +00:00
Sandra Lokshina 370de78b2c Add DAI SS stream to the demo page.
Closes #1169.

Change-Id: I85413d2197f96ba9a4bafc1ef668cf7a64ca26f6
2020-04-17 20:03:23 +00:00
Joey Parrish 63dec1b747 Fix missing EME polyfill in Cast receiver
This has not had an impact yet because we do not yet make use of the
encryption scheme queries that the polyfill provides.  But this
polyfill has been missing from the Cast receiver in all v2.5.x
releases since it was introduced.

The omission was first noticed when loading the Cast receiver in a
debugger in desktop Chrome.  This wouldn't normally be an issue with
most polyfills, but this one is outside of the Closure deps system.

Change-Id: I53685f5efe5555979993bf692d8a7cae31305ea9
2020-04-16 23:02:07 +00:00
michellezhuo 3b52166f56 Remove support for custom DASH ContentProtection schemas
Remove manifest.dash.customScheme callback function since it's no longer used.

Closes #2356

Change-Id: I6d08fcf97cff1bf2985e7c660d74efcd767eaed9
2020-04-09 09:11:20 -07:00
Joey Parrish 32ebfa730c Push demo app footer to the bottom of the page
For large screens, this fixes the empty whitespace below the footer.
The main content will now expand if necessary to push the footer to
the bottom.

Fixes: b/131849286

Change-Id: I8608e7f733a06c567ce5a01ea5b87f85f901c023
2020-04-07 17:59:17 +00:00
Theodore Abshire ae568e0649 Fix offline picking high-bandwidth codecs.
When playing an asset, the player will first choose a codec, based
on the lowest average bandwidth.
However, the storage mechanism did not have any such filtering;
instead, all it did (if using the default track filtering plugin) was
pick the middle-bandwidth audio track. This lead to it sometimes making
different codec decisions than the player would have.
This CL breaks the codec filtering logic out into a helper function, and
calls it both for playback and storage.

It also adds headers comments to some functions in the demo page.

Closes #2390

Change-Id: I09f1a24753121afd0e7500577c0f64ccffe5a4d1
2020-04-02 22:46:10 +00:00
Theodore Abshire e90b3e0013 v2.5.x search hash parameters compatibility
When backporting the search parameters in hash feature to v2.5.x,
the mechanism behind it was modified to handle that branch's lack
of localized strings.
This updates the master version of the feature to follow that change;
now, instead of storing the value of the feature, we store the key.

Change-Id: Ic18aa2ff3d138a68cb3acc154aeb8c7e992daef3
2020-03-24 11:46:17 -07:00
Theodore Abshire a8927828e8 Add search filters to the URL.
Closes #2422

Change-Id: I567ad6b0368badcf1e8e2535a640adc650f4daea
2020-03-12 12:03:09 -07:00
michellezhuo c82ff51d1f Add a presentationDelay config for HLS live
Closes #2373

Change-Id: I627bbd226ed9cab9bc476e2c2a3257d2e2dbc0e9
2020-03-11 18:41:15 +00:00
Joey Parrish 97b4f3d47d Update service worker cache name
In preparation for v2.6, update the service worker cache.  Old caches
will be dropped, which should clean up any extraneous resources cached
by the v2.5 version.

Change-Id: Ief45857ba6033d65e4b267463f0a12a670b71535
2020-03-10 14:51:18 -07:00
Joey Parrish d224fc46a5 Activate service worker updates right away
Instead of waiting for all active pages to be closed and the old
service worker shut down, activate the new service worker right away
as soon as it is installed.

Change-Id: Ia49b6f44d026a934f46cb5cf2a86dc9de9274b0c
2020-03-10 14:51:18 -07:00
Joey Parrish e235a4fcbe Complain about missing resources for compiled-mode PWA
If the demo app is running in compiled mode, the PWA service worker
will now complain about any local resources that are requested by the
app but not marked for caching.  This helps catch missing resources in
the service worker's resource lists.

Change-Id: Ia7f65f8ca6679e5c4ba29a1474a42aa97f33278b
2020-03-10 14:51:18 -07:00
Joey Parrish ebfde6422d Don't cache everything from the demo origin in service worker
Before this change, location.origin appeared in a list of cacheable
URL prefixes in the service worker.  This was a lazy way of making
sure that all node modules, translations, etc. would be cached without
being explicitly listed.  But it also meant that we could wind up
caching the uncompiled sources, which can complicate debugging if they
are inadvertently pulled from cache on reload.

This change adds the missing local resources that can't be listed
explicitly (translations, logos) by using absolute URL prefixes.

Change-Id: I4963516ec392e7607f86bc891bcdcf46c141951d
2020-03-10 14:51:10 -07:00
Joey Parrish 3d3a2c7fb9 Convert relative URL list to absolute in service worker
The URLs of critical and optional resources will now be converted to
absolute URLs.  This will allow the exact URL matching against those
lists to work, which will let me subsequently remove location.origin
from the list of cacheable URL prefixes.  (In a follow-up commit.)

Change-Id: I886d11435c96944f9b50ebf937dd329357f5c257
2020-03-10 14:50:29 -07:00
Joey Parrish f76624545e Fix exact URL lookup for PWA cache
Some of the request URLs in service worker fetch events contain has
parameters, which breaks our exact URL lookups for critical and
optional resources.  This fixes the lookups by removing hash
parameters.

Change-Id: I56b22a2faa42e2f3c28bd82fae4e8feedc83d408
2020-03-10 14:50:26 -07:00
Joey Parrish 25f28f8301 Add missing node modules and IMA SDK to PWA cache
Change-Id: I20d45fd729c487c55b88e695a213cd3955b54241
2020-03-10 14:50:10 -07:00
Joey Parrish 5387bf6f46 Fix missing await in service worker
Without the "await" on timeout, try/catch would not catch a timeout
error, leading to request failures in some cases.

This bug is present in v2.5.x as well as the master branch.

Change-Id: I3a0c8cd46265d41bade8117edd3cb92ac597d4fd
2020-03-10 14:50:00 -07:00
Joey Parrish 09147b1273 Update references to "search" tab to "all content"
Change-Id: I77dcc3055b58216db26de7a003b0fd980c779e76
2020-03-10 17:14:51 +00:00
Joey Parrish 95a2814e75 Re-enable DASH live sim streams
Now that Dash-Industry-Forum/dash-live-source-simulator#91 is
resolved, we can re-enable these streams.

Change-Id: I958ccdbf48741703d46d00c4e69a0fc3916249b7
2020-03-04 12:04:25 -08:00
Theodore Abshire 25396ce403 Load pwacompat through npm.
Loading pwacompat off of jsdelivr was flagged as a security issue
through an automated scan. Since Google does not control jsdelivr,
that is theoretically true.
This just loads a local version of pwacompat via npm, and uses that
instead.

Change-Id: Iba9288a1d440dfdfa039a32b530f6da981c5b055
2020-02-28 10:43:14 -08:00
Theodore Abshire 277dd859b4 Replace Live search boolean with a drop-down.
This adds an option for searching for VOD. It also changes the Live
search option to be a drop-down instead of a toggle, so as to prevent
users from trying to search for assets that are both Live and VOD.

Change-Id: Ib03a64128aea6d06baff23fc1d909090fdf7ef79
2020-02-27 21:34:51 -08:00
Theodore Abshire 192cb9d1f7 Replaced "Undefined" with "---" in demo.
"Undefined" was a bit confusing as a search term... does it mean
that you aren't searching for anything, or that you are searching for
things with "Undefined" as a value?
Hyphens are a clearer non-search value.

Change-Id: Ie2a542620265ae1f1ca167f18ca311d15d76acf7
2020-02-27 15:22:52 -08:00