Source: lib/device/hisense.js

  1. /*! @license
  2. * Shaka Player
  3. * Copyright 2025 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. goog.provide('shaka.device.Hisense');
  7. goog.require('shaka.device.AbstractDevice');
  8. goog.require('shaka.device.DeviceFactory');
  9. goog.require('shaka.device.IDevice');
  10. goog.require('shaka.log');
  11. /**
  12. * @final
  13. */
  14. shaka.device.Hisense = class extends shaka.device.AbstractDevice {
  15. /**
  16. * @override
  17. */
  18. getVersion() {
  19. return null;
  20. }
  21. /**
  22. * @override
  23. */
  24. getDeviceName() {
  25. return 'Hisense';
  26. }
  27. /**
  28. * @override
  29. */
  30. getDeviceType() {
  31. return shaka.device.IDevice.DeviceType.TV;
  32. }
  33. /**
  34. * @override
  35. */
  36. supportsMediaCapabilities() {
  37. return false;
  38. }
  39. /**
  40. * @override
  41. */
  42. detectMaxHardwareResolution() {
  43. const maxResolution = {width: 1920, height: 1080};
  44. let supports4k = null;
  45. if (window.Hisense_Get4KSupportState) {
  46. try {
  47. // eslint-disable-next-line new-cap
  48. supports4k = window.Hisense_Get4KSupportState();
  49. } catch (e) {
  50. shaka.log.debug('Hisense: Failed to get 4K support state', e);
  51. }
  52. }
  53. if (supports4k == null) {
  54. // If API is not there or not working for whatever reason, fallback to
  55. // user agent check, as it contains UHD or FHD info.
  56. supports4k = navigator.userAgent.includes('UHD');
  57. }
  58. if (supports4k) {
  59. maxResolution.width = 3840;
  60. maxResolution.height = 2160;
  61. }
  62. return Promise.resolve(maxResolution);
  63. }
  64. /**
  65. * @override
  66. */
  67. adjustConfig(config) {
  68. super.adjustConfig(config);
  69. // Hisense has long hardware pipeline that respond slowly to seeking.
  70. // Therefore we should not seek when we detect a stall on this platform.
  71. // Instead, default stallSkip to 0 to force the stall detector to pause
  72. // and play instead.
  73. config.streaming.stallSkip = 0;
  74. return config;
  75. }
  76. /**
  77. * @return {boolean}
  78. * @private
  79. */
  80. static isHisense_() {
  81. return navigator.userAgent.includes('Hisense') ||
  82. navigator.userAgent.includes('VIDAA');
  83. }
  84. };
  85. if (shaka.device.Hisense.isHisense_()) {
  86. shaka.device.DeviceFactory.registerDeviceFactory(
  87. () => new shaka.device.Hisense());
  88. }