Commit Graph

42 Commits

Author SHA1 Message Date
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 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 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 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 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
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
Jacob Trimble 326f5cd02a Use short license in more files.
Some of the files still used the old long license.  This increased the
size of the compiled bundle since it had both versions.

Change-Id: Iec137f71547f91369a563145f870eb26ddc96a96
2020-02-11 19:09:44 +00:00
Joey Parrish 4a7aee1daf Customize default UI config for desktop/mobile
To match Chrome native controls, the default controls for desktop will
now contain the small play/pause button, but default controls for
mobile will now contain the large play/pause button.  Mobile controls
will also not contain the volume button.

This removes several CSS-based versions of these things in preference
for configuration.

Apps can still override the defaults, no matter the platform.  Apps
can also make their own mobile-based config choices in JS by checking
video.ui.isMobile() or change styles in CSS using ".shaka-mobile".

Change-Id: I4fb8391f7f3727c7086cd3bca2b1d5c93bd9e856
2020-01-18 23:24:33 +00:00
Joey Parrish 400d5a9faf Add "fadeDelay" option to delay fading UI controls
This option will be used in our cast receiver to delay fading the
controls for a few seconds when playback begins.

Change-Id: Ia44c2eb6cd4fc9c40f07b0336556a87762f2ee14
2020-01-14 10:42:36 -08:00
Joey Parrish 361e39eaa6 Revert recent cast changes
This reverts commits:
 - a43f52caf3
   "Add "noFade" configuration to UI."
 - 08a36e886f
   "Add transparency transition cast app controls."
 - a6b159ffcf
   "Keep controls visible while casting."

Moving the showing/hiding up to the receiver app level can waste CPU
on low-end devices, and puts undue configuration burden on the
receiver app.

We will follow up with a more direct fix for #2314, as well as a
"fadeDelay" option to allow the cast receiver UI to delay fading for a
few seconds.

Related to issue #2314

Change-Id: I0028803432ad028930002b29dd7b94c7d9a0ec56
2020-01-14 03:04:45 +00:00
Theodore Abshire 08a36e886f Add transparency transition cast app controls.
Beforehand, the controls would fade in and out primarily due to an
unintentional interaction with the UI fade transition effect.
With other changes, though, that interaction is no longer working, so
here is an explicitly-defined transition.

Change-Id: I5ec3ef1ab4267affc348d7ed035586ba8c1abc1a
2020-01-10 23:43:47 +00:00
Theodore Abshire a43f52caf3 Add "noFade" configuration to UI.
This allows users to tell the UI to stay visible at all times, even if
there are no mouse events.
This is necessary on ChromeCast, where there is no mouse, or touch
controls, or anything; without this setting, the controls just stay
transparent all the time.

Change-Id: Ie74c689f9bee9f07ffcb68dbacfd7bfe3ad066de
2020-01-10 23:43:37 +00: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
Theodore Abshire 4c6325de08 Added localization system to demo.
No localizations exist currently, but this adds the framework for them.

Change-Id: I81a8cab128884753c765a192181d5d88f0ed13f1
2019-11-18 19:41:58 +00:00
Theodore Abshire f24c4a783f Added stylelint, a linter for our CSS/less files.
Also unified CSS/less style based on that.
This does have to use a forked version of stylelint, since there
is a bug (?) in the globbing library they use that causes it to
fail on our buildbot. I found the simplest solution was just to add
an option to disable globbing, a feature we weren't using anyway.

Closes #1867

Change-Id: I9295b01d5b15d060356e314938b64b551b75de6a
2019-08-08 18:38:19 +00:00
Joey Parrish 6aa35d1433 Fix text display styles
Changes to text styles:
 - Default to 20px instead of 18px
 - Default to a black background (issue #1955)
 - Fix the line height (otherwise set in px by MDL in the demo app)
 - Scale font with the window in fullscreen or cast receiver

Fixes #1955

Change-Id: I98da85030f4b5a40ba1be962b3d1b4fc2c34489e
2019-06-05 20:08:08 +00:00
Joey Parrish e54f729a04 Deprecate ui.getPlayer for controls.getPlayer
The controls have the cast proxy and the proxied player, so the UI
itself offering direct access to the local player is confusing.
Instead, we will send all requests through the controls, which have
explicit getPlayer() and getLocalPlayer() methods for access to the
proxied and local players.

Closes #1941

Change-Id: I1d6154d76b1b3b5b550e55e39efcbb2c451f7569
2019-05-16 18:30:16 +00:00
Joey Parrish 525136025d Update cast receiver to ES6
Issue #1157

Change-Id: I6ac26db7e84bdb478065b04463afebc3a6693cd6
2019-05-15 16:30:13 +00:00
Jacob Trimble f130dffcef Enable eslint indentation rule.
This is a fully automated change.  The linter will fail because the
extra indentation caused line-length errors.  These won't be fixed
automatically.  They are fixed in a follow-up to make this one fully
automated.

Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
2019-05-13 22:31:09 +00:00
Jacob Trimble 0dd64074b9 Only allow one statement per line.
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
2019-05-13 22:11:50 +00:00
Joey Parrish 279add1c1b Pre-connect to external origins
This optimizes the demo app by establishing HTTPS connections early.

Change-Id: I600c89d24db91e36fa201939514b42cca804e57a
2019-05-13 17:42:00 +00:00
Joey Parrish 58cedb0367 Add @license to all LESS and CSS files
Change-Id: Ibefe715afcb3676d5a2694032b9c99fe98dd2c44
2019-05-10 17:26:14 +00:00
Joey Parrish 34585af993 Inline external CSS for quicker load
This reduces the number of resources we have to load by using LESS to
import them into the compiled CSS bundle.

This also gets rid of a flash of unstyled content in compiled mode by
always including the compiled CSS in HTML directly, regardless of
mode.  If the app is running in uncompiled mode, LESS is still loaded
and can override the compiled styles.

Change-Id: I8cde25c15c281029a129225fc85a8baee767f424
2019-05-09 19:05:17 +00:00
Jacob Trimble 47daf49f31 Use arrow functions for callbacks.
This is an automated change to convert use of "function" functions
to arrow functions.  This doesn't change all uses of bind() that
could be converted.  This also doesn't remove all "function" functions.

Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
2019-05-09 16:40:46 +00:00
Jacob Trimble c81389741f Prefer const over let.
A coming update to the Google eslint config will require using "const"
over "let".  This makes that one change to isolate the big changes.

Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
2019-05-08 09:22:10 -07:00
Joey Parrish 2f6ffabcab Fix cast receiver styling
The cast receiver should not be managing play button state or styles.
Doing this causes the play button to be off-center by interfering with
UI styles.

This also drops all outdated styles that are no longer used with the
new UI.

Reconfiguring the receiver UI controls gets rid of extra elements that
are not used in this context.

Fixes b/131254481
Fixes b/131254837

Change-Id: I25fb34a9b6a3e18fb07f3570181edbbf14a31cd3
2019-05-07 21:28:46 +00:00
Joey Parrish 9e853bcd84 Fix flash of audio-only poster in cast receiver
The audio-only poster was showing before there was really anything
loaded.

Change-Id: Icc62e3dd90b748491444150c16ccbb3d69081a7c
2019-05-07 16:03:19 +00:00
Theodore Abshire efc2ed3df1 Added new demo page.
This is a complete replacement for the old demo page, made to be more
modern-looking and easier to maintain. It contains new features such as
remembering the URIs you provide for custom assets, and searching through
the default assets by feature.
This demo page is not quite ready for release yet, but it's getting close.

Change-Id: Iad01d1fc02c3cd238d73b9b9e02dbb4301cb6f2a
2019-05-01 19:58:18 +00:00
Theodore Abshire 4b1fffa886 Fix controls.css location in cast receiver html.
When we switched to using less for our css, we forgot to update
the cast receiver to point to the compiled css. This corrects that.

Change-Id: Ib5d9336fc1b14233731004be845b819be2b20307
2018-12-21 23:08:42 +00:00
Theodore Abshire 9fe3b2fe78 Fix fetching ui elements on cast receiver app.
Change-Id: I1f5ef7a573a6cbb85365e6e8a195f777190d956a
2018-12-21 22:37:53 +00:00
Sandra Lokshina 6b1ca2d229 Initial release of Shaka Player UI
Other contributors:
 - @joeyparrish
 - @michellezhuogg
 - @TheModMaker
 - @theodab
 - @vaage

Change-Id: If6df33d9ab5035d1ead4402004f7de37ee8470f4
2018-11-16 14:40:37 -08:00
Joey Parrish fd0449d8f7 Re-enable some disabled style rules
This re-enables the following style rules:
  - "block-spacing"
  - "brace-style"
  - "comma-dangle"
  - "comma-spacing"
  - "new-cap"
  - "no-multi-spaces"
  - "no-multiple-empty-lines"
  - "one-var"
  - "padded-blocks"
  - "prefer-rest-params"

Change-Id: I15d616e8d5b88b273ded6128b4f9ad86bdb26bd1
2018-07-09 19:44:56 +00:00
Joey Parrish 66abf9cb27 Remove all protocol-relative URIs
According to @beaufortfrancois, we should no longer be using protocol-
relative URIs.  He quotes this passage from Paul Irish:

> Now that SSL is encouraged for everyone and doesn’t have performance
> concerns, this technique is now an anti-pattern. If the asset you
> need is available on SSL, then always use the https:// asset.

> Allowing the snippet to request over HTTP opens the door for attacks
> like the recent Github Man-on-the-side attack. It’s always safe to
> request HTTPS assets even if your site is on HTTP, however the
> reverse is not true.

Source: https://www.paulirish.com/2010/the-protocol-relative-url/

This change was begun with the following command:
  git grep -l "'//" | xargs sed -i "s@'//@'https://@g"

Some changes made by that command were false-positives, which I then
reverted manually.  Others required additional cleanup to meet style
rules.

I've also just discovered that the "max-len" rule in eslint's Google
style config exempts URIs, so there's no need to disable the max-len
rule on URIs in the assets list.  These have been removed in the asset
list where unnecessary.

Finally, testing these updated URIs led to the discovery that two of
our third-party demo assets are no longer available.  One URI needed
to be updated.  The other had no obvious replacement, so it was
removed.

Closes #1390

Change-Id: I2fe23faec04f1904c1741236b364d5089900092a
2018-04-09 18:06:18 +00:00
Jacob Trimble 2a130473dc Convert 'var' to 'let'/'const' (9 of 9).
This is part of a change to convert all usages of 'var' with either
'let' or 'const'.  This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.

Change-Id: I270c70f6cda733ca6121d0761b4c1c162104d379
2018-02-20 11:30:04 -08:00
Jacob Trimble 117ed46bd5 Add links to switch between compiled and uncompiled
This also modifies the build scripts to produce debug builds of the
demo and the receiver when doing debug builds.

Change-Id: I386a7b8f541332594a5022955a69970ebbe79200
2017-10-17 17:26:37 +00:00
Joey Parrish 51263249f6 [PWA] Do not block rendering to load JavaScript
Reported by lighthouse

Issue #905

Change-Id: Iee9623ab4fabe1432cca72bb9d329e8a07d26bb8
2017-10-02 11:19:10 -07:00
Joey Parrish 958e1c68dd [PWA] Compile the demo app and cast receiver app
When using the compiled version of the library, use a compiled version
of the demo app, as well.  This makes use of the generated externs, so
we now have additional confidence that they are correctly generated.

Refactor the load.js script to use a configurable list of sources.
This enables us to use the same load.js in both the demo and cast
receiver.

This, ultimately, makes it easier to cache demo resources in our PWA.

Issue #876

Change-Id: I274660fe2ea23236ceea3c2d3c97572762d2f785
2017-10-02 11:19:10 -07:00
Jacob Trimble e63c967ad4 Remove old YouTube test assets.
Since they are old, not being updated, and don't represent the kind of
content we want to support, just drop them.  This also avoid extra
work to handle YouTube's custom DRM callbacks.

Closes #1015

Change-Id: Iefa9b7a34cd184549ff0895e96198907cc6c8a51
2017-09-11 15:46:25 -07:00
Joey Parrish a2a7c2f4ad Add player.isAudioOnly()
This simplifies detection of audio-only content and makes the process
a little more obvious.

Closes #942

Change-Id: I89b599fb8c8915c9e1b45d2f9b81a3ac7193e5ef
2017-07-31 23:03:51 +00:00
Joey Parrish 160dd1d7db [PWA] Move cast receiver code
This makes it easier to compile the demo and receiver apps, which will
make the PWA transition easier.

Issue #876

Change-Id: Iffd335df35c17c7895f763ccf180011dd1d8c14d
2017-06-22 22:51:37 +00:00