In our tests, we can load the library many times. Each time, the
polyfills get installed, so each polyfill must be able to handle being
installed twice, and avoid any bad behavior.
The InputEvent polyfill, which is used on IE only to get correct UI
behavior on input elements, was only able to handle being installed
twice if each call was on the same copy of the library. In our tests,
this is not the case. If we load the library 20 times, we get the
polyfill installed 20 times.
Since it was comparing addEventListener with the polyfilled version,
this check would fail when the library was reloaded. Each "shaka"
namespace was distinct. So on 20 hypothetical library loads, each
polyfill would delegate to its predecessor, creating a stack some 40
functions deep. This would trigger a stack overflow when testing on
IE.
Instead, we can store the original addEventListener in some global
place, such as on HTMLInputElement.prototype.originalAddEventListener.
If that exists, the polyfill (or some version of it) was installed, so
we don't install another.
Found in Jasmine upgrade process (issue #1949)
Change-Id: I714631c9b3ac5c59cf82a5cf7501cb544d1cb5cb
Two patches in the IE EME polyfill became undefined during the ES6
conversion. These mistakes were caught by a newer compiler.
setMediaKeys was declared on a different class (MediaKeySystemAccess).
And both setMediaKeys and requestMediaKeySystemAccess needed to be
declared static in order to be referenced from a static install
method.
Issue #1852
Change-Id: Ibbeb57bb3f25e84826ab094681717fdaf1b5a8b7
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
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
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
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
By listening to events on document in the capturing phase, we can
avoid complex event shims on HTMLVideoElement. By monitoring
global PiP state on the document, we can get rid of the getter and
setter for the document's PiP element, as well.
Follow-up on PR #1902
Change-Id: Ib5f5d0c7c735124a438901c5bb15e034ab10b996
Safari on iOS does not support HTML5 fullscreen API. There
seems to be a (separate) way for a video element to enter
fullscreen mode. I will see if we can adopt it in a different CL.
For now, just hide the button if fullscreen API is not supported.
Issue #1909
Issue b/131923216
Change-Id: Ia30660c7a68fd626051fdf5abce59dbe993b2de2
- Polyfill navigator.languages, which is missing on IE
- Add missing handler for uncaught exceptions (doesn't work on IE,
but is a good idea to have for debugging the demo app)
- Avoid offline setup if it's not supported (as on IE)
- Fix bad reference to uncompiled link (wrong ID)
- Log any caught errors to the console
- Wrap the init functions to catch and log any errors during init
Fixes b/131863587
Fixes#1911 (similar storage error on iOS)
Change-Id: Ib2a53392d5632c71825af17dd3e955cd54279e98
The unprefixed EME launched with macOS 10.14 (Mojave) rejects requests
for the key system IDs we know how to use. So until the bug we filed
against Apple is resolved, prefer the prefixed API.
Issue #382
Change-Id: I71313be2102af2da66a6389a9e9afdebd8ae033d
This adds a polyfill for Apple's prefixed EME implementation. This
will be used on all macOS versions prior to 10.14 (Mojave) and on
Safari versions prior to 12.1.
This also adds support for FairPlay license protocol eccentricities
in DrmEngine, so that the proper formatting is used for requests and
responses.
Issue #382
Change-Id: If1274d2f018a475f56c09df97645694f13acbde9
Instead of triggering src= based on 'video/mp4' MIME types, ask the
browser what it can support using video.canPlayType().
Querying canPlayType() also allows us to detect src= support for
native HLS in Safari.
The original version of this change also added a complete fallback
system to detect MIME types based on common file extensions and
fetch MIME types via HEAD request when necessary, but the load graph
system does not yet allow us to make async decisions about destination
node. So this async MIME detection is commented out for now.
Closes#816 (src= single file playback)
Issue #997 (native HLS in Safari)
Change-Id: If1930ca4fd5710481a925d63fb312d9a5b15fec8
This CL creates the "loaded with src=" node and its initial
implementation. Adding this node required some changed to the routing
logic as a new destination was created.
We will use src= when given mp4 content or media source is unavailable.
We detect mp4 content via the mimeType in |load| and/or the file
extension. When media source is not available on a platform, we fall
back to using src=. To do this, we check if media source is available
whenever |load| is called, and will route to the src= branch if media
source is not found.
To avoid pre-initializing media source (when it is not available) we
modify the |initializeMediaSource| flag in |attach| and |unload| when
media source is not available.
Doing this showed that we had inconsistent behaviour between |attach|
and |unload|. |attach| would default to initializing media source
whereas |unload| would not. This has been fixed.
Issue #816
Issue #997
Change-Id: I00599832b49c9079e273e65a4b827fee736479cc
- Fix the link to Dolby's Dolby Vision Profiles and levels PDF
- Was pointing to a document version that no longer exists
- Update Dolby Vision regex to match all DV codecs
- Dolby Vision is available in 4 different (base) codecs: dvhe, dvh1, dvav, dva1
- dvh* represents HEVC-based Dolby Vision
- dva* represents AVC-based Dolby Vision.
- Do not remove Dolby Vision codecs on Chromecast
No need to remove Dolby Vision codecs on Chromecast. Chromecast's canDisplayType will reject them when the cast receiver or the attached display can't play Dolby Vision.
On Dolby Vision capable cast receivers attached to a TV in Dolby Vision mode, canDisplayType does not reject Dolby Vision streams. One such device is the Chromecast Ultra. With this change, Shaka Player plays Dolby Vision on qualifying setups.
This CL limits the use of |setTimeout| by wrapping it in our own timer
class. The timer class makes it easier to track and cancel time-based
events.
To ensure that|setTimeout| is not used outside of our timer classes, the
conformance rules have been updated to only allow |setTimeout| to be
used by our timer classes.
Since |setTimeout| is very similar to |setInterval|, the conformance
rules for |setInternal| rules were updates to reflect more of the logic
behind why we don't want to use |setTimeout| and |setInterval| directly.
Change-Id: Iff5da32a61b515dd2016837fa74a34c04b6c5fd2
Tizen Smart TVs do not play opus content well when using MSE. To prevent
Shaka Player from trying to play opus content on Tizen, we override
media source's isTypeSupported to reject opus content.
Since most content will have AAC as a fallback, this should not limit
playback on Tizen.
Issue #1751
Change-Id: Ia61a1d26f547082fa68a9f38e4af16951191dd4f
Now that we have Safari 12 in the lab, we have found that it requires
the same MediaSource polyfills as Safari 11.
Fixes b/120434307
Change-Id: I45f8be79d0aca7987ffcba1ce13b8589a2287712
To make it easier to know where we are check what platform something is
(normally a sign of a work-around), this change isolates the logic to
make the check into functions.
Now looking for uses of |shaka.util.Platform| should show when we are
using platform-specific logic.
Change-Id: Ief49837c503e951f7138ec08a83355fe1c46db88
- We can get a 'msneedkey' event with no init data.
- Use the correct message type name.
Issue #1689
Change-Id: Ic0e54fe8331d4700971d78095b77831de2d9580b
This replaces almost every instance of indexOf on both String and
Array. There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.
Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
https://goo.gl is being turned-down, so we can't use it for new URLS.
So we have consistent short links, this converts them to be
https://bit.ly.
Change-Id: I07a86cba807b67157664893341f648023918d0de
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: I225f5c7e54adf4cca8512cddae082ba50ed82e4e
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: I2bfa4d531a8fcdcf9578e9c181c4534ad7443b7a
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: Ibcaf21382bd78b91e589122983dd14e001bfdad5
Now each EME polyfill can be removed independently; this allows
someone to remove just the IE11 polyfill while still keeping the
others.
This adds a priority ordering to the polyfills so the nop polyfill
will be run last as a fallback if there are no other polyfills.
Issue #1261
Change-Id: I865e1c0d6a73a079dd91505e96572e215e6f6c6a
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: I6a329d28e13a81c9f7136737518c6bb8fa18402e
A bug in our Promise polyfill caused issues with the recently-added
AbortableOperation class on IE11. Since external polyfills for this
are smaller, it is easier to remove ours in favor of a third-party
polyfill. Applications that wish to support IE11 must now load this
additional polyfill.
We are using the "es6-promise-polyfill" module from npm, but any
compliant polyfill should suffice.
One feature our own polyfill offered was the ability to flush all
Promises, which allowed us to write synchronous unit tests that
simulated async processes. To get this ability back, we are now
using the "promise-mock" module in our tests.
Getting "promise-mock" to load correctly involved switching from
"requirejs" to "cajon", which builds on requirejs and supports
AMD modules more directly.
Closes#1260
Change-Id: I5de48e88a910736ae5c1897a7a509bc5641acb70
This digests and organizes many of the automatic settings in eslint,
and changes several of them to be more strict. This also fixes the
following errors:
- array-callback-return
- no-catch-shadow
- no-multi-spaces
- no-new
- no-throw-literal
- no-useless-call
- no-useless-concat
- no-useless-return
Several checks have been organized into a group of checks we should
use, but need more time to implement and fix. Some other checks have
been delegated to the Closure compiler, which can more precisely
whitelist exceptions.
Issue #1157
Change-Id: I8fe4966959e08050f8159e6a1fee161e7d71177e
The eslint configuration is derived from analyzing the style of our
sources as they are now, plus a few tweaks.
In particular, we have disabled checks for undefined variables and use
of console, both of which the compiler handle with greater precision.
The compiler already knows what is defined in the environment through
our externs, and has specific exceptions for the use of console (demo,
tests).
We have also disabled a few checks that we should use, but will
require many changes to the code: no-unused-vars, no-redeclare,
and comma-dangle.
This commit also fixes several types of eslint errors that were easy:
- no-useless-escape (unneccessary escape characters in Regexp)
- no-constant-condition (using true/false/0/1/etc in if/while)
- no-fallthrough (caught an actual bug in one EME polyfill)
- no-irregular-whitespace (we had a UTF-8 nbsp in externs)
- no-cond-assign (using an assignment inside a conditional)
To satisfy stricter provide/require checks in the Closure Compiler
Linter, we will no longer use provide/require at all in tests. We
will still use provide in test utilities (test/test/util/) since it
sets up the namespace for us. But we will not use require there
because there is no deps management for test code.
Issue #1157
Change-Id: Icc44f51feeb568ea7d3980e693e92e560d897afd
This change enables an additional conformance check in the compiler
which prevents us from committing code where the compiler fails to
infer what "this" means.
None of these changes constituted actual bugs, just inference failures
in the compiler.
Issue #1130
Change-Id: If9b18203768e197258042a9b4339530f371ed831
SourceBuffer.remove, when told to remove exactly up to a keyframe,
will also remove that keyframe and all of the content till the next
keyframe. This results in far too much content being deleted, and is
breaking our tests on Safari 11.
Patching this by offseting the end of the removal range by 1ms seems
to be a viable workaround.
Closes#1048
Change-Id: I062b2dc2617f1372f885f4ccbc906d77c65412d7
Because Safari's support for TS via MSE is broken, reject all TS
content in Safari. Transmuxing (#887) will compensate.
https://bugs.webkit.org/show_bug.cgi?id=165342Closes#743
Change-Id: Iff8a6a7c159e48a4f388d99396915752e649c6ac
There are several issues with isTypeSupported on Chromecast that
require workarounds in JavaScript:
- Dolby Vision strings must be removed from the codecs parameter,
even though the content is supported by the platform
- HDR must be guessed at from the codecs parameter and an additional
parameter must be added to query HDR support
- Queries must be made through a non-standard interface
Change-Id: I4c8c70e70cf9c26283913783f5f62f7d6470c2f1
The HTML5 'input' event does not work correctly on all input elements
in IE 11. There are equivalent events that the UI can use on IE.
Instead of remembering this and checking for IE every time the 'input'
event is needed, let the polyfill translate the event type.
Change-Id: I23258a5c6a0bd37e946214380ad07949f3ee7f88
Two EME polyfills currently assume persistent storage support: one
for old Tizen TVs and other older embedded Chromium devices, and one
for IE11.
This backfires when an application is trying to detect support for
encrypted offline content.
By removing this assumption, we do not convey support for EME features
that are not known to be available on these devices.
Change-Id: If427eeda1cde60341a2b57f76744c2adfdb34beb
This is part of adding a new conformance rule to add additional type
safety. This will disallow using properties of unknown types or using
unknown properties.
The first parts will be fixing errors caused by the new rule. These
are backwards compatible, so can be applied before the rule is enabled.
Once all the errors and bugs are fixed, the rule will be enabled.
Change-Id: Iefde089b2f62ddfdf43944cda5badab438577561