Instead of calling video.load() and waiting for loadeddata for src=,
wait for loadedmetadata. This should be a safe event to use in most
cases, and calling video.load() causes native HLS to start preloading
an uncontrollable amount of content.
The exception is if the app sets preload='none' on the video element.
If this happens, we will detect it, log a warning, and avoid the
loadedmetadata event which may never fire. This is not a scenario we
will officially support, but at least we can prevent a hang in
player.load().
Closes#2483
Change-Id: Id64c8f23cb8fa82bb5c301abafb51f2d9d8730f7
For some reason, the new compiler in the master branch let this by,
but the old compiler in the v2.5.x branch complained when I
cherry-picked the utility.
Change-Id: I1e688f72594b74ed7d2a7c2801eb179b8ec13e8c
While developing screenshot-based layout tests, it was discovered that
IE 11 did not position VTT/TTML regions in the same way as other
browsers. This turned out to be caused by a bug in IE's flexbox
implementation in which flex items that are center-positioned can
overflow the flex parent.
This uses the work-around recommended here:
https://github.com/philipwalton/flexbugs/tree/6e720da8#flexbug-2Closes#2584
Change-Id: I22b9790b8f5798ba757a111d2c502dd5a3415441
The margin: auto style centers the element both horizontally and
vertically. We don't want vertical centering, and we already get
horizontal centering when appropriate through other styles. So
removing margin: auto is the best fix.
Closes#2524
Change-Id: Icff74e49b3917b50141d1205232ebb0856fbcf16
In HlsParser, fetchPartialSegment_() is meant to fetch the starting part
of the segment to get the segment's start time, so we don't have to
download the full segment if possible.
PART_SEGMENT_SIZE is the default size of the starting part of the
segment we fetch.
Low Latency HLS introduces 'Partial Segment' as a smaller part of
a regular segment, such as CMAF chunks, and a regular segment might be
divided into many partial segments.
Renaming the original function and field to improve code readability and
avoid any future confusion.
Issue #1525
Change-Id: I593497f6e99e9ffe6128d6976eb7886bbd79679c
This fixes the missing shaka.log in debug builds by exporting it
explicitly with the Closure Library API if goog.DEBUG is set.
Closes#2565
Change-Id: I4edd3220997f890058b693cec3bdf295ab5c171c
The timestamp parser in our HLS parser should not fail on null TS
packets. These are indicates by a packet ID of 8191 (0x1fff), and
according to the spec, should be skipped by any receiver.
We will not skip such packets and continue through the segment to find
a PES packet with a timestamp.
In addition to the comments in #2546, I found this document helpful:
https://www.mikrocontroller.net/attachment/27265/mpeg2ts.pdfCloses#2546
Change-Id: Id9dc16160bbde03969199150ca50122f12de77f4
The position: 'absolute' style should only be set when other
positioning attributes (left, right, top, bottom) are being set.
Otherwise, the natural layout flow is disturbed, without anything to
replace it.
Closes#2524
Change-Id: I4062c68253218a0f4ace6560a8847381d80c48d5
@exportInterface is used by the extern generator, but ignored by the
compiler. @export should be used for shaka.polyfill.
Closes#2549 .
Change-Id: I400db152ec8ca222a45a598ab58ddfbe44552443
Setting text track visibility to true may, in some cases, require us
to choose a text track. But we should not do this if one has already
been chosen.
Closes#2553
Change-Id: I53bf1b624b59baae774ffaeb0f0e9eb5467984fc
When no specific size has been set on a Cue object, the default will
now be 0, which means "auto" size to the text displayer. If a cue has
no specific width, the background will fit to the text. If a cue has
an explicit width of 100%, the background will fill the entire
horizontal space of the text container.
This fixes the 100%-width background introduced in Change-Id
I4500b8f637f3f43f48d019d14ef527e75d960fec in #2524.
Fixes#2524
Change-Id: I98caeb89d3da640a8175560810c8ccf2de27a2bb
The destroy method on SegmentIndex is needed for backward
compatiblity, so it should definitely be exported in v2.6, as it was
for v2.5.
Change-Id: Id29faea5ae1719f1ea9201808aa9ce674574afc7
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
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
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
Also add a note to the MSE polyfill about restrictions being applied
in Player as well. We used to restrict Safari versions only in the
polyfill, and I had forgotten about the other version check.
Closes#2548
Change-Id: I4d2f319939c3a079e7f0ec7134876d91fc425bf4
When we construct final streams in period flattening, we start them
off original streams and then combine streams from each period that
best matches the characteristics of the original stream.
The original stream also participates in the matching process, but
it was possible for it not to get selected as the best match if
there were other streams with similar characteristics.
This change adds logic to always prefer the original stream if
it's encountered.
Also, this change adds a bandwidth comparison for audio
streams to ensure the closest streams get matched bandwidth-wise.
Issue #2537.
Change-Id: I5d99a452a12ea1c4bb70fa8aba4bec479ff9d27b
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
We changed SegmentIndex from IDestroyable to IReleasable since v2.5.x,
so this adds compatibility for the v2.6 release to avoid breaking
existing apps.
Change-Id: I3a12eec98c9af58fe08f0aec7e499266b70e9b48
It does not make sense to truly export an abstract interface. This
should always have used the exportInterface annotation.
Change-Id: If170b41b89728dd549669cee0c606de492b79ad9
When SimpleTextDisplayer is constructed, a TextTrack is created,
and that cannot be removed. This introduces an extra TextTrack when the
content is played in src= mode.
This is the straight-forward solution to filter the extra TextTrack out
by the label in src= mode.
Issue #2516
Change-Id: I8c417f837e4ad2f90ec779b533c8484de9e22b11
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
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
The old compiler would let us export a static method on a class
without exporting the whole class and its constructor. The new
compiler silently ignores `@export` for any methods of a non-exported
class.
This means that for the latest Closure Compiler, we must export any
class with exported static methods. In some cases, these are
non-utility classes with constructors we'd rather not export, but the
constructor is implicitly exported by exporting the class itself.
This was initially caught by the integration tests. The error wasn't
especially helpful, so I added a try/catch to loadShaka that makes the
error more apparent:
TypeError: Cannot read property 'registerParserByMime' of undefined
To make sure we do not make this mistake again, I've added a check to
the extern generator, which was already able to detect these types of
classes. I don't know a compiler-based way to do it, since the
compiler silently ignores the export annotations in these cases.
Issue #2528
Change-Id: I797c75a8098b0bb3cf837588569f878253dec2cf
Before we buffer a segment, video.currentTime will be 0, even for live
streams. So this should not be used in getPlayheadTimeAsDate().
Instead, we should use the Playhead time or the time that will be used
later once content is loaded.
Bug: 149549467
Change-Id: I585fd2364003021839bc16724f41510637489326
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
The built-in externs for IndexedDB in Closure Compiler are missing
some type info. This overrides them to add what's missing.
This also tweaks type information in a few places in lib/offline/ to
match.
This was caught by a compiler upgrade.
Issue #2528
Change-Id: I97096656f53b426067219e2d4e3aa16f32b87188
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
The new Closure Compiler complains that a number|string union from a
map in MpdUtils is used in a calculation. In practice, we know that
this specific value is always a number, so we add an assertion to
satisfy the newer compiler's type checks.
Issue #2528
Change-Id: Id12de47d2dd4a12f9cc35879bee8da5ee25cdd70
In "Remove extraneous exports" (Change-Id
Iaf142397f31bd927bf942499a79da595f77361d5), I removed an export that
was actually required in the newer compiler. This replaces the
missing export.
Issue #2528
Change-Id: I3e9ec7085d813365dab917b4712571585d2286c8
In many places, we check error codes on shaka.util.Error. But the
compiler doesn't know that what is caught in "catch" is that type, so
we add type assertions.
In some cases, we know that other types may also be thrown, so there
are also some runtime checks. Some of these had to be refactored to
allow the compiler to correctly infer types.
Change-Id: I053bd7e96213c689aae3889315052dd402124690
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
The latest Closure Compiler initially complained about "initData" not
being a known property of "Event". Correcting the type to
MediaEncryptedEvent exposed a potential bug, which is that we were
assigning Uint8Array in some cases instead of the correct ArrayBuffer.
This fixes both the type of the event and converts the Uint8Arrays to
ArrayBuffers.
This also works around a complaint about "code" on "Error". We use
"Error" objects as look-alikes for DOMException because there is no
exposed constructor for DOMExceptions. To satisfy the compiler, we
use square brackets now to set the "code" field on these DOMException
look-alikes.
Finally, this removes the "method" field on certain Errors in the
WebKit EME polyfill. These must have been leftover from some
debugging, and are not used at all.
Issue #2528
Change-Id: I32c4617b14a30c412d5bc532ec17a46fdc1fea1a
These classes were over-idented, making formatting more challenging.
I wanted to fix this before making compiler-upgrade-related changes in
these files.
Issue #2528
Change-Id: Ic44448760161a3e724d8c92f41f07c1a0babfa72