Commit Graph

54 Commits

Author SHA1 Message Date
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00
michellezhuo e74dfde811 Revert "Fix playback rate display in UI"
This reverts commit 604a33d7b9.
Instead of adding another another getter method, we can change the
current behavior of the existing getPlaybackRate() function.

Reopens #2526.

Change-Id: Ic8e60220191ef89fbb2fb242aa7b8263e0409c4b
2020-05-06 15:19:00 -07:00
michellezhuo 604a33d7b9 Fix playback rate display in UI
1. When the video hasn't started playing and is buffering, display
playback rate as 1x.
2. When the video is buffering and the playback rate gets updated,
display the newly selected playback rate.

Closes #2526.

Change-Id: Idf074e402ef8fdd2905dee84dcd5f084f217342e
2020-05-06 19:17:56 +00:00
Joey Parrish f0caf4067c Fix serialization of Error objects over Cast
When the Cast receiver throws an Error or rejects a Promise with a
non-Shaka Error, we need to represent it to the sender in a reasonable
way.  Otherwise, it can be very difficult to debug.

Related to the investigation of #2487

Change-Id: Ia58dd1e1e56ee93bea9afc9d368084d53c381db3
2020-04-17 21:41:01 +00:00
Jacob Trimble 3fa7472086 Add non-nullable modifier to return types.
This is a copy of the internal CL: cr/299901617.

Change-Id: I49abbde9563f08819ec99dbc9deb99b66dd8053b
2020-03-11 15:46:06 -07:00
Jacob Trimble c49f24b31b Remove remaining deprecated features for v2.6.
Change-Id: I2199e3c960fe6319eb9ab342291dfd9a62d9090e
2020-02-24 15:57:05 -08:00
Theodore Abshire 78756198dd Add enum for player event names.
By having an explicit enum, we can make sure there are no typos in
FakeEvent creation calls. This change also allows the cast proxy and
receiver to proxy events based entirely on the enum; that way, they
do not need to maintain their own independent list of events, that
can potentially fall out of sync (see #2318).

Change-Id: I08fa6653f35d86e87efda7fc822c8988688cfcff
2020-01-07 21:35:23 +00:00
Joey Parrish 26583c5787 Add missing events to CastProxy Player
There were several events missing from the proxied event list.  This
adds all of them.

Closes #2318

Change-Id: Iaba752adcf8dbe1c1a9f28bfe36fd3084221bb98
2020-01-03 10:53:52 -08: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
Sandra Lokshina a70676826a Add a method to select variants by label.
This also addresses an old TODO about switching
variants and text separately.

Closes #924.

Change-Id: I46644ca04dfc8b36696696078c4f14ee15774356
2019-11-07 18:31:41 +00:00
Jacob Trimble 18b59c5294 Disallow using new Uint8Array with BufferSource.
Using "new Uint8Array" with a TypedArray creates a copy of the buffer;
this is unnecessarily expensive for large buffers.  This adds a rule
to disallow using it in favor of a new utility that correctly creates
a new "view" on the same buffer.

Note it is fine to pass an ArrayBuffer to "new Uint8Array" and it won't
copy; but there there are many cases where the type is BufferSource,
so it could be a TypedArray.  Unfortunately, there are many other cases
where we explicitly pass an ArrayBuffer; but the compiler rules don't
allow us to whitelist this case (since ArrayBuffer is part of
BufferSource).

Change-Id: I58696a85a9cbcc188c0b16919c9eeb63e56edca1
2019-08-21 20:40:59 +00:00
Jacob Trimble 5c35108cb8 Avoid integer for loops.
Issue #1518

Change-Id: I3ba3cb6a439264e823022b2a64e7cdbd265494c7
2019-07-09 17:11:49 +00:00
Michelle Zhuo 7dc95710f0 Update CastSender and CastUtils to ES6
Issue #1157

Change-Id: I6d72a7cb5c8b1e4cb783d53a5465b8e4bb1b7063
2019-05-31 17:30:31 +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
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
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
Joey Parrish 91c57e1663 Drop periodreadyforstreaming event
This event was added just for the sake of the UI tests, but the video
element's canplaythrough event works in its place.

Change-Id: I6774fdfdfbd2b197cc93eae743829510b61bb0fa
2019-04-30 17:07:08 +00:00
Álvaro Velad Galván bd291ef542 Add getLoadMode function (#1896)
Add a new function called getLoadMode that returns the current load mode

The possible responses are:
DESTROYED, NOT_LOADED, MEDIA_SOURCE and SRC_EQUALS

This function is necessary for #1003 because AirPlay only works with SRC_EQUALS mode,
and the AirPlay events fire even in MEDIA_SOURCE mode.
2019-04-29 09:39:41 -07:00
Sandra Lokshina 3721797cd2 Add abrstatuschanged event.
Add event to notify listeners when abr is being enabled/disabled.
The resolutions menu is listening for variantchanged events to
update itself. It's possible, however, that just enabled abr
will pick the same variant that's currently being played, in
which case, there'll be no variantchanged event. The resolution,
though, still needs to update to reflect the fact that 'Auto'
resolution is selected now and not a specific one.

Adding an event for when the abr state changes helps solve
this.

Fixes b/131099397

Change-Id: I63b218d7423cd0d389dd540c5ed05966e00b861c
2019-04-23 23:55:49 +00:00
Sandra Lokshina f121a89d33 Fire an event when a period is setup.
Add an event for when the app can safely switch streams without
the request being deferred. This is needed by the UI integration
tests to know when it's safe for them to start.

Change-Id: I49d0ae948fd350d342e6315e0dd62243b92be736
2019-03-27 10:58:54 -07:00
Theodore Abshire b6a3d7c05c Adds CastUtils special cases for Uint8Array
Using JSON.stringify and JSON.parse turns Uint8Arrays into generic
objects, but we need them to be actually be Uint8Arrays.
This adds a special case to CastUtil.serialize and CastUtils.deserialize
to preserve the object type of Uint8Arrays.

Closes #1716

Change-Id: I370711c016c5d5ba21cdbccb3d970c6e074a3edd
2019-01-22 18:55:01 +00:00
Joey Parrish 4f08dab6fb Stop resizing the play button in JS
Make the play button and spinner a simple 15% of video width.

Fixes b/116328412
Fixes #1715

Change-Id: I31708d0066a033e64ebdeb9fa603688c5f99860b
2018-12-18 22:40:10 +00:00
Michelle Zhuo 1afceadc9c Refactor Closed Captions Support for HLS
Refactor the closed captions support for HLS, using the same approach as
the closed captions support for Dash.
If closed captions are signaled in the manifest, player will create a
text stream for to represent the closed captions, and text engine will
store and append them. We don't need to set 'useEmbeddedText' value for
closed captions any longer.

Issue #1404

Change-Id: I9a5bf4df7e29d6e6982f29fd5e2df07bc78071d7
2018-11-27 20:59:52 +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 c49736f10b Fix typos and improve comments for getManifestUri
This fixes typos ("getManiestUri" and "depreciated") and puts more
concise comments around the deprecation of getManifestUri and the
handling of it in CastProxy/CastUtils.

Initially, I thought we had broken compatibility.  These fixes make
it clearer that we have not done so.

Change-Id: I0d2ace66a5753475b82d9e042e764d955bb23ae9
2018-08-07 23:18:33 +00:00
Joey Parrish 196590685d Stop proxying drmInfo()
Even a small drmInfo() serializes to 1kB, and it's not that useful.
Stop proxying these so that our messages stay reasonable in size
(< 5kB for a full update).

Change-Id: Iea6db214fe06a6bcc2828e8dc36fcd2ac57b63af
2018-08-07 23:18:33 +00:00
Aaron Vaage 272e6bd922 Merge Offline Config into Player Config
As part of the effort to allow storage to be initialized with or
without a player instance, this change moves the offline config
into the player config and changes storage to share a configuration
object with a player instance.

We opted to share the instance between the two classes because if
storage was initialized with player, the initializer is implying a
relationship between the two objects and therefore configuration
changes should be shared.

Issue #1297

Change-Id: I991365255e63c284fbfcf147cf63c9588dd764ab
2018-07-31 22:07:02 +00:00
Aaron Vaage c17114e29f Change |manifestUri| to |assetUri|
In preparation to supporting non-manifest assets, let's change
|manifestUri| to |assetUri| as it is a more broad name.

Issue #816

Change-Id: Ibec761caa8acf173571592ce0a7029af0f60de68
2018-07-25 18:10:39 +00: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 f0b9beb5a9 Fix small typos and formatting
Change-Id: Iaece5250c3d6ed9922852cfe71ee0e63c93a73fe
2018-05-09 10:40:06 -07:00
Michelle Zhuo 535de4db84 Refactor: Remove underscore from parameter names
Change-Id: Ie9e6fb59763f454f245175f23c6444f919ba8135
2018-05-08 19:21:51 +00:00
Joey Parrish 309bd915c0 Rename "getUse" to "using" EmbeddedTextTrack
This name reads a bit more naturally.  Also rewords some of the method
descriptions.

Change-Id: I03a9cb78f88637b6076d64b4c5cd852a69b37f99
2018-04-04 16:51:34 +00:00
Theodore Abshire dc17969822 Typo fixes and rewording in comments, part 1
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.

This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.

Change-Id: I048b430e4c0bea2ccb9aec572d5e9ec6b606a87a
2018-03-14 17:59:26 +00:00
Joey Parrish b27ea82e7f Allow Player to attach/detach from video
This adds attach/detach methods to replace the media element in the
Player constructor.  Now applications can take back control of the
media element or provide a reference later in the Player's life cycle.

This also allows applications to decide whether or not to set up
MediaSource in advance, through an optional argument on attach and
unload.  The default will be to set up MediaSource in advance, which
maintains current behavior.  This advanced setup of MediaSource can
improve load latency later.

This change also introduces async/await for the first time in the
project, which required changes to eslint config, Closure build
arguments, Babel & Babel-polyfill setup, and the esprima parser used
by our extern generator.

The use of async/await will improve readability in many places, and
these infrastructure changes to enable async/await should also unblock
issues #1336 and #1337.

Closes #1087

Change-Id: I0d6b4e0e2af27a6520a3d070fa92b7139b2cb8b0
2018-03-06 22:19:53 +00:00
Jacob Trimble 61fc107be3 Convert 'var' to 'let'/'const' (1 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: I8f857a24e4c1ad336177d23dfed4f4a29d3262d2
2018-02-13 13:40:02 -08:00
Michelle Zhuo 175e0b9594 Support CEA 708 Closed Captions
Issue #276.

Change-Id: If42ab04a451dc8c4c7038213b7f7c925648c3444
2018-02-03 00:03:44 +00:00
Sandra Lokshina 2b920e228f Add role selection to the demo app
Closes #967

Change-Id: I3a83a85b327901a6ab071b355e6cd890a13d7550
2017-12-18 11:31:17 -08:00
theodab 8ed316d3c2 Reduced frequency of some getters on cast updates
Not all values need to be updated twice a second. This change modifies
the list of player getters so that each value also includes an update
frequency, and only updates that property once in that many updates.
This acts as a configurable way to ensure that some properties update
in different amounts, without having to have multiple update timers or
compose multiple update messages in the same timeframe.

Change-Id: I90e75e3e73f6c633d91b1799307ec2b15587327b
2017-12-14 21:02:48 +00:00
Joey Parrish e97a93d396 Drop cast serialization special case
Removes a special case in serialization that is no longer relevant due
to a configuration interface that was removed for v2.3.

Change-Id: I87ed194f42c1c25d86ca45b7ac952d6a45119a26
2017-12-14 10:28:10 -08:00
theodab 31b2984f6b Stopped proxying getManifest()
getManifest() hugely increased the message size when casting, to the
point where we were having message size problems.
This CL stops that property from being proxied.

This also adds an integration test that makes sure update messages do not get
too large.

Closes #1128

Change-Id: I3c4bfabb4d35ee870a603c38f784cb226366a28b
2017-12-13 22:16:30 +00:00
Michelle Zhuo bd37a7c161 Add Streaming Event and Manifest Getter Method
Adding an event right after the player parses the manifest, and before
initiating streaming, so that users can get the manifest information.
Adding manifest getter method in player so that customers can access
manifest information.

Closes #1043
Closes #1074
Issue #1036

Change-Id: I0016c312bacdfa86299e5df68b586f90d565cfdc
2017-10-26 11:07:55 -07:00
theodab 1573c52167 Fix CastUtils.serialize handling of errors.
Beforehand, we stripped out all objects variables in events when
serializing. This was intended to remove complicated DOM objects, and
prevent the error messages from containing large amounts of unnecessary
information. However, this also caused the cast receiver to strip away
the detail variable in error events, thus removing all useful
information from the error event.
This adds a special exception to serialize for the contents of the
'detail' variable.

Issue #1065

Change-Id: Ie291e317cc6e856af20af5df57ecf3b5c81ec8bd
2017-10-18 17:45:00 +00:00
Jacob Trimble b4d4294efc Add Player method to get buffered ranges.
Change-Id: I8237dc1d0b42a1d96bbd51cbd1c02ff58dd372f4
2017-10-17 16:24:53 +00:00
theodab 95d2855b8f Fixed a problem with live-only getters on cast
Beforehand, the Chromecast would poll getPlayheadTimeAsDate and
getPresentationStartTimeAsDate for every update message, which are live-only
getters, even on VOD.
This would cause a lot of error messages in the debug output of the receiver;
we didn't notice this before because we mostly run the receiver in compiled
mode.
This also allowed users to poll those attributes for VODs without any error
messages when casting, since the results of the last update were cached.

This change adds a list of getters that require live; such getters are not added
to state update messages, and are set up with asserts in the sender.
This should solve the problem and slim down our update messages a bit at the
same time.

Change-Id: Ifc0b445def2d85b22fcb9af160dec2205d1faace
2017-08-28 17:57:58 +00:00
Jacob Trimble 30450f8cbb Fix Chromecast tests and add missing members.
There was a bug in the cast_utils test that meant that the new members
on Player weren't being detected.  The test should fail when we forget
to add a new member to the list in cast_utils.js.  This updates the
test and adds the new members to the list.

Change-Id: I27c25d07b409b8350b5709c3ce26696d72a6a11d
2017-08-18 17:51:52 +00:00
Joey Parrish 6834054906 Remove deprecated methods for v2.2
The getTracks and selectTrack methods have been deprecated since v2.1
and scheduled for removal in v2.2.

Change-Id: I938b3015262d71683ac871c05a9f4c74c96acf50
2017-08-10 18:56:09 +00:00
Sandra Lokshina 843f020008 Chromecast: add support for Media Playback messages.
Media Playback messages are used by generic Chromecast controllers
(Google Home app and the likes). Supporting them is required by
the Chromecast SDK.

Closes #722.

Change-Id: I3c98fb9d63da81b59c2cc82a3e790332fc9bb56e
2017-04-11 19:00:54 +00:00
Jacob Trimble b4d0fa4901 Expose license expiration times through Player.
This adds a method on Player to get the license expiration times for
the current EME sessions.  This also adds the expiration times to the
stored content structure for offline content.  This will update the
stored expiration while playing content (e.g. license duration changes
when playback starts).

Closes #727

Change-Id: I18770a79413423695bbb2ed5f31f6b19038a33d2
2017-04-03 18:25:43 +00:00
Jacob Trimble 87c7d5d665 Add framework for events on the media timeline.
This add the groundwork for event regions that occur while playing.
When the playhead enters (or plays through) a specified region it will
fire enter/exit events for it.  They are not fired when seeking over.

Issue #462

Change-Id: I9e280796bd012ad74d0319aa2056c6f6aa28890d
2017-01-20 22:19:33 +00:00