Commit Graph

279 Commits

Author SHA1 Message Date
Joey Parrish 6c85c8cbfc fix: Fix rendering of TTML nested cues and spacers
TTML nested cues are meant to be displayed horizontally as inline
elements.  This fixes the rendering of these nested cues in both
SimpleTextDisplayer and UITextDisplayer.

In UITextDisplayer, the styles have been adjusted to lay out the
nested cues horizontally rather than vertically.

In SimpleTextDisplayer, the nested cues were being displayed as if
they were top-level cues.  This change concatenates the nested cues
into a single cue displayed in the browser.

This also improves comments on the poorly-named "spacer" property,
which represents a line break in TTML.

This fixes the rendering of "spacer" in SimpleTextDisplayer by
inserting an actual newline character into the collapsed nested cues.

Finally, this fixes and clarifies names used internally in
UITextDisplayer.  For example, there is a difference between a nested
cue and leaf cue.  A nested cue and a top-level cue without nested
cues are both "leaf" cues, but a top-level cue is never a "nested"
cue, since it is at the top level.  The conflation of these names
before this fix made it difficult to understand and fix the code in
the first place.

Closes #2760

Change-Id: I89633761d12704e253371d17e2e786c5b2ed67a7
2020-07-30 11:29:55 -07:00
Álvaro Velad Galván fac29133c2 Add AirPlay button to overflow menu (#2701)
feat(UI): Add AirPlay button to overflow menu.
2020-07-14 15:55:15 -07:00
Muhammad Haris d53fbaeeeb fix: Fix disappearing captions with certain input patterns (#2674)
When the subtitles are turned off, unloadTextStream() on streaming engine is called, but currentTextStream is never set to null. When the captions are turned back on, a check in player.js sees that the current text stream is not null, so it assumes it exists, and is ready to go. Thus captions are never loaded.

Clearing (setting to null) the current stream on unloadTextStream ensures the text stream is properly initialized the next time it is called, and in a state so that captions can resume being parsed.

After further investigation, it seems that the unit tests are written in a way that assumes that the text stream is nulled when unloadTextStream is called. So this fix is definitely something that we assume already happens.

Closes #2671
2020-06-24 13:12:09 -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
Theodore Abshire 6694d3c13e feat(UI): Add forceLandscapeOnFullscreen UI config
This is a UI configuration that forces the device to orient to
landscape mode when the video goes fullscreen.
It may or may not work on all platforms, due to being based on an
experimental browser API.
It is true by default.

Issue #883
Closes #2653

Change-Id: I947bfb84e77f65b38bcf8a1572d70a04a3073ba0
2020-06-16 21:22:48 +00: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 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 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
Joey Parrish f76afcc853 fix(ui): Set an explicit font size for icons
We depended on this font size being set in the font server's CSS, but
did not realize we had this implicit dependency.  This makes our
desired font size explicit.

This protects us from applications which happen to use the same font
and class name with a different default size.  Note that applications
which intend to change our icon size can still do so explicitly in
their own styles.  This is meant only to protect against accidental
conflicts.

Closes #2633

Change-Id: I0a2993c8b2e39596b47eb59b7e1a4a6373633c0b
2020-06-09 19:16:23 +00: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
Joey Parrish 5d2dc2daaf Update deprecation timelines (v3.1 => v4.0)
Since we are getting strict about semantic versioning, we can't remove
features in v3.1.  Any backward compatibility we offer will be
maintained until v4.0.

The exception is explicit IE 11 support, which will still be removed
in v3.1.

To help us follow the rules for removal, the Deprecate utility no
longer accepts a minor version argument.

Change-Id: I4dd94a6084e4ed72eeec410eb9aa0ad974d8dac8
2020-06-01 15:57:31 -07: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
Sandra Lokshina 43b9567b5b Propagate UI locale changes to ad manager.
Change-Id: I4de1a8a5d16c9b2d8efb71eb94df70ae73fc0c3f
2020-05-26 15:29:10 +00:00
Joey Parrish ac2a7039b4 Make the controls background gradient proportional
Rather than making the gradient 92px tall, make it 15% of the size of
the video container.  This is consistent with the size of the controls
and the position of the subtitles when the controls are shown.

In this way, the size of the gradient is now proportional and
responsive to the size of the video container.

This was spotted while developing screenshot-based layout tests using
relatively small containers.

Change-Id: I304d99a26be90b9eefa50dc179b924da15dc601d
2020-05-21 16:19:58 +00:00
Joey Parrish 4592a090ae Remove controls container when destroying the UI
Removing the controls container when destroying the UI restores the
DOM back to its pre-constructor state after destroy() is complete.
This allows the video container to be reused.

This became an issue while developing screenshot-based layout tests.

Change-Id: I5aa74e9ef443037ad84ac6c8acf7d09f657d6b5e
2020-05-21 16:19:54 +00:00
Joey Parrish 6e95843d09 Rename skim to scrim
We might have misunderstood something the UX team said early on in our
UI efforts, but this element that partially obscures the background is
called a "scrim", not a "skim".

See https://travishorn.com/responsive-scrim-6f286da5b6a5

Change-Id: I483eb38deb9d98b9fc22b45772992029d43a4b65
2020-05-21 16:19:39 +00:00
Joey Parrish 09ea6e6526 Make UI immune to extra destroy() calls
Change-Id: Icb46e1a837187c2d1b7e5832fab0c07433163eb8
2020-05-21 16:19:29 +00:00
Joey Parrish d215994123 Fix renaming of ad-related shaka.ui.Element fields
This also changes the Element plugin renaming test to avoid a
hard-coded list of member names so we don't miss one in the future.

Change-Id: Ifeb3b951ea3422da5014f16d9dcb13e8b8c7fc45
2020-05-13 21:33:07 +00:00
Joey Parrish c998ce2721 Fix live seek bar on touch screens
The UI seek bar on touch screen devices was broken in PR #2036 and
v2.5.4 - v2.5.11 for live content.  VOD content, which starts at 0,
was unaffected.

This fixes the range calculations for touch events to correctly
account for the minimum seek range.

Closes #2558

Change-Id: Ic3f6230d88703fd0ea1c9bc15057c0656b1dc42f
2020-05-12 21:14:13 +00:00
Joey Parrish 9695c68bb7 Fix demo app close button
As an external, abstract interface, the constructor doesn't do
anything.  The members in it were parts of the base class
shaka.ui.Element, which implementations of IUIElement can still
inherit from.

However, I was wrong about this part of the extern being unnecessary.
It turns out to prevent the compiler from renaming those critical
parts of the base class.  Application-provided UI elements (such as
our demo's close button) break without these definitions being part of
the library build.

This reverts commit 89059f81e5 ("Remove
bogus parts of IUIElement interface") and adds a comment to the
interface definition that would have prevented me from making this
mistake in the first place.  It also adds a regression test to the UI
test suite.

Change-Id: I712d985a6287136d68dc0a888662badd7e306b9e
2020-05-12 19:05:13 +00:00
michellezhuo 252c41dbc3 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: I2e8764cfabdcc675a94e26bd9cd18cbc056a35f9
2020-05-06 16:52:26 -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
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 89059f81e5 Remove bogus parts of IUIElement interface
As an external, abstract interface, the constructor doesn't do
anything.  The members in it were parts of the base class
shaka.ui.Element, which implementations of IUIElement can still
inherit from.

In fact, there is not much reason to have this empty IUIElement
interface now, but we'll keep it for now to avoid breaking compiled
applications.

Change-Id: I5687b281be523c29656b5c51e63628ba164cf1b3
2020-05-02 14:55:47 +00:00
Joey Parrish 7c189a5b39 Add backward compatibility for IUIElement release
We changed IUIElement from IDestroyable to IReleasable since v2.5.x,
so this adds compatibility for the v2.6 release to avoid breaking
existing UI element plugins apps may have.

Change-Id: I38e90cda80048669834bbc8e5ad5650c3df32f10
2020-05-01 21:06:29 -07:00
Theodore Abshire 697a565051 Change positioning of line-positioned subtitles.
Previously, we were positioning subtitles relative to the video,
but this lead to problems with subtitles that were manually positioned
(via the line attribute) to be low (85% or lower); they would overlap
with the controls bar, and thus be hidden.

This changes cues to be positioned relative to the text-usable area of
the screen (e.g. the space above the controls bar). In addition, the
less values have been changed to not trim cues that extend out of the
container, so that if they do overlap with the controls, they aren't
clipped in an ugly way.
Examining the Chrome native controls, this appears to be closer to how
they render captions.

Fixes #2524

Change-Id: I4500b8f637f3f43f48d019d14ef527e75d960fec
2020-05-01 20:31:55 +00:00
Joey Parrish 11f3347a48 Fix static method aliases
We used to alias static utility methods by assigning the method itself
to a local variable.  This is not allowed by the new Closure Compiler
release that we are adopting, and for good reason.

The old compiler did not understand the use of "this" in static
methods, but the new one does.  And it turns out that when we start
using "this" in static methods (see #2532), aliasing the method itself
can break everything.

When you refer to "this" in a static method, it refers to the class.
This is really useful in utility classes that have private static
methods they use to perform common tasks.  However, just as it ruins
the value of "this" to alias an instance method, the same is true of
an ES6 class's static method.

The fix is to always alias the class instead of the method.  The new
compiler will simply not let us get away with the old way any more, so
regressions after this are unlikely.

Issue #2528 (compiler upgrade)
Issue #2532 (static "this")

Change-Id: Id800d466e639c7cbcf4aa6fbb05114c772a2229f
2020-04-30 19:28:53 +00:00
Joey Parrish 342d35f4f9 Fix issues with nullability of numbers
Various issues with the nullability of number types led to various
fixes, including:
 - defaulting a nullable number to 0 to avoid propagating a null value
   through calculations
 - adding an assertion or runtime check that something is not null
 - moving an existing null check to before the calculation
 - returning early on null during an iteration
 - changing a nullable number to non-nullable
 - defaulting to NaN instead of null

These issues were caught by a compiler upgrade.

Issue #2528

Change-Id: I86d516c74a42ee3624c33d7513d2d4c76d3ea589
2020-04-30 16:00:00 +00:00
Joey Parrish a955d9f189 Fix UI keyboard Event types
The latest Closure Compiler is more picky about Event types, and
complained about the use of "key" on Event.  This updates the Event
types so that the compiler has the correct type info.

This also stops using "keyCode", which is deprecated, and only uses
the current "key" property, which is even supported on IE, and should
not create any compatibility issues.

Issue #2528

Change-Id: Ic565772b1cc9597e358df015a73c40ac245edd6a
2020-04-28 21:41:02 +00:00
Joey Parrish c1d849bc9b Fix UI button types
The compiler is very picky about the use of the "disabled" property on
HTMLElement, since it is only defined on certain subclasses of that.
This adds a method to create a button with the correct type to satisfy
the compiler.

Issue #2528

Change-Id: I31cacd62a35acc87b245ab362dbab55d791cf34d
2020-04-28 21:40:53 +00:00
Joey Parrish 8867db6773 Fix implicit string-to-number conversions
This was caught by a compiler upgrade.

Issue #2528

Change-Id: Ica262703aa30dce2e59c139c88f3c1e74d5d9e2f
2020-04-27 17:33:06 -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
michellezhuo 030147c7f4 Avoid displaying duplicate vtt cues
Closes #2497

Change-Id: Ibc4de196f500d8685244217f9a056d8b12c05f8a
2020-04-20 22:58:45 +00:00
Joey Parrish d5e20b5ea8 Fix Shaka UI controls in Cast receiver
The Cast receiver does not ever change the controls between our UI and
the native controls, but the demo app does.  So in the demo app, we
never noticed that they do not seem to show up by default any more.
This fixes the UI library to show its own control by default, which in
turn fixes the Cast receiver app and any other app which did not use
setEnabledShakaControls().

Change-Id: I7889f1a7ec612bc7a260f5433316104d64ad4a26
2020-04-16 16:04:16 -07:00
michellezhuo 002c52c2c1 Add configuration to enable/disable fullscreen-on-rotate
Closes #2494

Change-Id: If66521593d80dd7ddb983c320ebd9c35343f6594
2020-04-11 22:31:00 +00:00
michellezhuo 6d171f7d5a Add configuration to enable keyboard playback controls
When set the configuration to true, using keyboard to control playback
will be enabled, such as seek forward/backward, jump to the
beginning/end, play/pause by press the space key, etc.

Closes #2489

Change-Id: I0e46bd5853d47855aae6e6dedcc7de8798bf4298
2020-04-10 23:56:06 +00:00
Joey Parrish 99de217c23 Remove periods from manifest structure
This removes periods from the internal manifest structure and cleans
up code and tests accordingly.  This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.

Three test cases have been disabled for the moment.

Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.

Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes #892 (refactor StreamingEngine)

Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
2020-04-09 19:22:16 +00:00
Joey Parrish f8f64799ef Fix/remove extra keydown listener in UI
After leaving tab navigation, we would wind up with an extra callback
fired on keydown.  This drops the duplicate.

Change-Id: I4e7bc0c433e5648759788a9c1a70267844c2e3f1
2020-04-09 09:38:51 -07:00
Joey Parrish 11cbb267c5 Fix broken docs for UI control events
The event namespaces were wrong, so the generated docs had broken
links.

Closes #2385

Change-Id: I9348dedc1a41edee127548e7f80c7e426ffd237e
2020-04-07 23:37:51 +00:00
Joey Parrish cbbc1c5fc2 Dismiss UI overflow menus on window click
In addition to dismissing the overflow menu when the video is clicked,
dismiss when any part of the window is clicked.  This is no different
from our event listener on the window for key events, so it should not
negatively impact applications.

Fixes: 131843503

Change-Id: Icc5f16f25d74ee5de88f5a928074c4f995a8dea6
2020-04-07 21:28:49 +00:00
Theodore Abshire 461144ba80 Fix placeholders in existing localization files.
Issue #2485

Change-Id: Ibcb82f9dd8ba43bc87d2955909fc160171ea0a7d
2020-04-07 13:45:30 -07:00
Sandra Lokshina fcc27b144a Hide overflow menu while ads are playing.
Change-Id: Ia77f0996c919e78b0a08b90e878c5615dcccf5bf
2020-04-07 18:32:13 +00:00
Joey Parrish 50724e2a91 Fix UI failure on destroy
When destroying the UI, it destroys the CastProxy & Player.  Then the
Player destroys the AdManager.  The AdManager then triggers events
that the UI elements listen to.  Those events cause the UI elements to
invoke the destroyed CastProxy.

Therefore it is important to destroy the UI elements before the
CastProxy and Player.

This was discovered while working on an unrelated issue, by observing
errors logs from automated UI tests.  The logs contained exceptions
with stack traces.

Change-Id: I6c1d070255bb138967d5e733c0c7ec8dd16350b6
2020-04-03 16:24:07 +00:00
Joey Parrish 4f2b3d63b9 Update translations
Change-Id: I386fd9d23b4dcf352a4b910f4b47885755486867
2020-04-01 17:02:17 +00:00
Joey Parrish d55ef50159 Minor formatting cleanup
This fixes syntax highlighting of this file in Vim.

Change-Id: I415b6d4855d5b05d9473e474ef2f057bcfb2c8c4
2020-03-27 15:49:37 +00:00
Joey Parrish 7a42c09477 Fix cursor style on skip-ad button
Without this, you can't tell that the button is clickable when you
mouse over it.

Change-Id: I571803d0ac3bd9416282de96eb20bce478770546
2020-03-26 21:02:49 +00:00
Joey Parrish b245b1ef57 Fix locale update on skip-ad button
Without this, it may not show the correct language.

This bug was discovered while updating our locale-based easter egg.
If you like reading commit messages, and you like easter eggs, maybe
go hunt on our appspot demo.  ;-)

Change-Id: Ie01143a7d419fb51438e763e00fe299424549c9a
2020-03-26 13:13:50 -07:00
Joey Parrish 88ebd5bcd7 Add translations for tier 2 languages
These are not compiled into the library by default, but can be with
the --locales option to either build/build.py or build/all.py.  They
can also be lazy-loaded on-demand, as in our demo app.

There are still some missing translations for Finnish ("fi"), Hebrew
("iw"), and Indonesian ("id").

This also corrects the list of tier 1 default languages in the build
scripts.

Change-Id: I992d7bebbb4e04d55b7992ecaee1d85bb6c1c5da
2020-03-23 16:56:37 +00:00
Joey Parrish b7b0456136 Update tier 1 & metalanguage translations
This updates the translations for all tier 1 languages and
metalanguages (ar-XB, en-XA).

Change-Id: Iea6b5b23f74fedacbf03284d514ede11a187496d
2020-03-23 16:56:37 +00:00