Source: lib/polyfill/encryption_scheme.js

  1. /*! @license
  2. * Shaka Player
  3. * Copyright 2016 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. goog.provide('shaka.polyfill.EncryptionScheme');
  7. goog.require('shaka.device.DeviceFactory');
  8. goog.require('shaka.polyfill');
  9. /**
  10. * @summary A polyfill to add support for EncryptionScheme queries in EME.
  11. * @see https://wicg.github.io/encrypted-media-encryption-scheme/
  12. * @see https://github.com/w3c/encrypted-media/pull/457
  13. * @see https://github.com/shaka-project/eme-encryption-scheme-polyfill
  14. * @export
  15. */
  16. shaka.polyfill.EncryptionScheme = class {
  17. /**
  18. * Install the polyfill if needed.
  19. *
  20. * @suppress {missingRequire}
  21. * @export
  22. */
  23. static install() {
  24. // Skip polyfill for PlayStation 4 and SkyQ devices due to known crashes
  25. // caused by unsupported encryptionScheme handling. These platforms do not
  26. // require the polyfill, and forcing encryptionScheme processing can result
  27. // in playback crashes.
  28. const device = shaka.device.DeviceFactory.getDevice();
  29. if (!device.supportsEncryptionSchemePolyfill()) {
  30. return;
  31. }
  32. EncryptionSchemePolyfills.install();
  33. }
  34. };
  35. // Install at a low priority so that other EME polyfills go first.
  36. shaka.polyfill.register(shaka.polyfill.EncryptionScheme.install, -2);