@gcorevideo/player 2.19.14 → 2.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/assets/level-selector/list.ejs +2 -2
  2. package/dist/core.js +2 -2
  3. package/dist/index.css +780 -780
  4. package/dist/index.js +1720 -1473
  5. package/dist/player.d.ts +425 -94
  6. package/dist/plugins/index.css +1466 -1466
  7. package/dist/plugins/index.js +1501 -1252
  8. package/docs/api/player.bottomgear.getelement.md +56 -0
  9. package/docs/api/player.bottomgear.md +51 -0
  10. package/docs/api/player.bottomgear.setcontent.md +56 -0
  11. package/docs/api/player.clapprnerdstats.md +12 -259
  12. package/docs/api/player.dvrcontrols.md +5 -1
  13. package/docs/api/player.errorscreen.attributes.md +3 -0
  14. package/docs/api/player.errorscreen.bindevents.md +3 -0
  15. package/docs/api/player.errorscreen.container.md +3 -0
  16. package/docs/api/player.errorscreen.hide.md +3 -0
  17. package/docs/api/player.errorscreen.md +27 -0
  18. package/docs/api/player.errorscreen.name.md +3 -0
  19. package/docs/api/player.errorscreen.render.md +3 -0
  20. package/docs/api/player.errorscreen.show.md +3 -0
  21. package/docs/api/player.errorscreen.supportedversion.md +3 -0
  22. package/docs/api/player.errorscreen.template.md +3 -0
  23. package/docs/api/player.errorscreen.unbindevents.md +3 -0
  24. package/docs/api/player.gearevents.md +49 -0
  25. package/docs/api/{player.sourcecontroller.name.md → player.gearitemelement.md} +5 -3
  26. package/docs/api/{player.playbackrate.template.md → player.initeventdata.event.md} +3 -3
  27. package/docs/api/{player.playbackrate.updateplaybackrate.md → player.initeventdata.md} +15 -11
  28. package/docs/api/player.levelselector.md +9 -1
  29. package/docs/api/player.md +124 -4
  30. package/docs/api/{player.clapprnerdstats.render.md → player.mediacontrol.getrightpanel.md} +8 -4
  31. package/docs/api/player.mediacontrol.md +14 -0
  32. package/docs/api/player.mediacontrolelement.md +1 -1
  33. package/docs/api/player.pictureinpicture.md +9 -197
  34. package/docs/api/player.playbackrate.md +10 -314
  35. package/docs/api/player.sourcecontroller.md +0 -90
  36. package/docs/api/player.spinnerevents.md +49 -0
  37. package/docs/api/player.spinnerthreebounce._constructor_.md +3 -0
  38. package/docs/api/player.spinnerthreebounce.hide.md +5 -0
  39. package/docs/api/player.spinnerthreebounce.md +14 -95
  40. package/docs/api/player.spinnerthreebounce.show.md +6 -37
  41. package/docs/api/{player.playbackrate.onplay.md → player.stalleventdata.count.md} +5 -7
  42. package/docs/api/{player.playbackrate.name.md → player.stalleventdata.event.md} +3 -3
  43. package/docs/api/player.stalleventdata.md +112 -0
  44. package/docs/api/player.stalleventdata.time.md +13 -0
  45. package/docs/api/player.stalleventdata.total_ms.md +13 -0
  46. package/docs/api/{player.pluginsettings.md → player.starteventdata.event.md} +3 -5
  47. package/docs/api/{player.playbackrate.onrateselect.md → player.starteventdata.md} +15 -11
  48. package/docs/api/player.subtitles.hide.md +5 -0
  49. package/docs/api/player.subtitles.md +23 -275
  50. package/docs/api/player.subtitles.show.md +5 -0
  51. package/docs/api/{player.statistics._constructor_.md → player.telemetry._constructor_.md} +6 -3
  52. package/docs/api/player.telemetry.md +146 -0
  53. package/docs/api/{player.volumefade.name.md → player.telemetry.name.md} +4 -2
  54. package/docs/api/{player.sourcecontroller.supportedversion.md → player.telemetry.supportedversion.md} +4 -2
  55. package/docs/api/player.telemetryevent.md +89 -0
  56. package/docs/api/player.telemetryeventdata.md +15 -0
  57. package/docs/api/player.telemetrypluginsettings.md +57 -0
  58. package/docs/api/player.telemetrypluginsettings.send.md +13 -0
  59. package/docs/api/player.telemetryrecord.md +17 -0
  60. package/docs/api/player.volumefade.md +0 -93
  61. package/docs/api/{player.pictureinpicture.name.md → player.watcheventdata.event.md} +3 -3
  62. package/docs/api/{player.playbackrate.setselectedrate.md → player.watcheventdata.md} +15 -11
  63. package/lib/index.plugins.d.ts +2 -2
  64. package/lib/index.plugins.d.ts.map +1 -1
  65. package/lib/index.plugins.js +2 -2
  66. package/lib/playback/hls-playback/HlsPlayback.js +1 -1
  67. package/lib/plugins/bottom-gear/BottomGear.d.ts +20 -1
  68. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  69. package/lib/plugins/bottom-gear/BottomGear.js +28 -7
  70. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +38 -5
  71. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
  72. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +67 -21
  73. package/lib/plugins/dvr-controls/DvrControls.d.ts +5 -2
  74. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
  75. package/lib/plugins/dvr-controls/DvrControls.js +5 -2
  76. package/lib/plugins/error-screen/ErrorScreen.d.ts +5 -0
  77. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
  78. package/lib/plugins/error-screen/ErrorScreen.js +5 -0
  79. package/lib/plugins/index.d.ts +2 -3
  80. package/lib/plugins/index.d.ts.map +1 -1
  81. package/lib/plugins/index.js +2 -3
  82. package/lib/plugins/level-selector/LevelSelector.d.ts +10 -3
  83. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  84. package/lib/plugins/level-selector/LevelSelector.js +20 -19
  85. package/lib/plugins/media-control/MediaControl.d.ts +6 -2
  86. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  87. package/lib/plugins/media-control/MediaControl.js +40 -39
  88. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +32 -4
  89. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  90. package/lib/plugins/picture-in-picture/PictureInPicture.js +30 -2
  91. package/lib/plugins/playback-rate/PlaybackRate.d.ts +47 -14
  92. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  93. package/lib/plugins/playback-rate/PlaybackRate.js +38 -9
  94. package/lib/plugins/source-controller/SourceController.d.ts +9 -0
  95. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  96. package/lib/plugins/source-controller/SourceController.js +11 -1
  97. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +35 -1
  98. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  99. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +46 -23
  100. package/lib/plugins/statistics/Statistics.d.ts +38 -3
  101. package/lib/plugins/statistics/Statistics.d.ts.map +1 -1
  102. package/lib/plugins/statistics/Statistics.js +51 -9
  103. package/lib/plugins/subtitles/Subtitles.d.ts +65 -16
  104. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -1
  105. package/lib/plugins/subtitles/Subtitles.js +131 -109
  106. package/lib/plugins/telemetry/Telemetry.d.ts +135 -0
  107. package/lib/plugins/telemetry/Telemetry.d.ts.map +1 -0
  108. package/lib/plugins/telemetry/Telemetry.js +180 -0
  109. package/lib/plugins/volume-fade/VolumeFade.d.ts +7 -1
  110. package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -1
  111. package/lib/plugins/volume-fade/VolumeFade.js +8 -1
  112. package/package.json +1 -1
  113. package/src/index.plugins.ts +2 -2
  114. package/src/playback/hls-playback/HlsPlayback.ts +1 -1
  115. package/src/plugins/bottom-gear/BottomGear.ts +26 -4
  116. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +240 -173
  117. package/src/plugins/dvr-controls/DvrControls.ts +5 -2
  118. package/src/plugins/error-screen/ErrorScreen.ts +5 -0
  119. package/src/plugins/index.ts +2 -3
  120. package/src/plugins/level-selector/LevelSelector.ts +22 -19
  121. package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +47 -26
  122. package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +18 -18
  123. package/src/plugins/media-control/MediaControl.ts +43 -41
  124. package/src/plugins/picture-in-picture/PictureInPicture.ts +35 -7
  125. package/src/plugins/playback-rate/PlaybackRate.ts +53 -24
  126. package/src/plugins/source-controller/SourceController.ts +11 -1
  127. package/src/plugins/source-controller/__tests__/SourceController.test.ts +1 -1
  128. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +46 -22
  129. package/src/plugins/subtitles/Subtitles.ts +146 -155
  130. package/src/plugins/telemetry/Telemetry.ts +299 -0
  131. package/src/plugins/volume-fade/VolumeFade.ts +9 -2
  132. package/temp/player.api.json +3384 -4872
  133. package/tsconfig.tsbuildinfo +1 -1
  134. package/docs/api/player.clapprnerdstats.attributes.md +0 -17
  135. package/docs/api/player.clapprnerdstats.bindevents.md +0 -18
  136. package/docs/api/player.clapprnerdstats.events.md +0 -18
  137. package/docs/api/player.clapprnerdstats.name.md +0 -14
  138. package/docs/api/player.clapprnerdstats.playerheight.md +0 -14
  139. package/docs/api/player.clapprnerdstats.playerwidth.md +0 -14
  140. package/docs/api/player.clapprnerdstats.statsboxelem.md +0 -14
  141. package/docs/api/player.clapprnerdstats.statsboxwidththreshold.md +0 -14
  142. package/docs/api/player.clapprnerdstats.supportedversion.md +0 -16
  143. package/docs/api/player.clapprnerdstats.template.md +0 -14
  144. package/docs/api/player.pictureinpicture.bindevents.md +0 -15
  145. package/docs/api/player.pictureinpicture.events.md +0 -13
  146. package/docs/api/player.pictureinpicture.exitpictureinpicture.md +0 -15
  147. package/docs/api/player.pictureinpicture.render.md +0 -15
  148. package/docs/api/player.pictureinpicture.requestpictureinpicture.md +0 -15
  149. package/docs/api/player.pictureinpicture.supportedversion.md +0 -13
  150. package/docs/api/player.pictureinpicture.togglepictureinpicture.md +0 -15
  151. package/docs/api/player.pictureinpicture.version.md +0 -11
  152. package/docs/api/player.pictureinpicture.videoelement.md +0 -11
  153. package/docs/api/player.playbackrate.attributes.md +0 -14
  154. package/docs/api/player.playbackrate.bindevents.md +0 -15
  155. package/docs/api/player.playbackrate.events.md +0 -15
  156. package/docs/api/player.playbackrate.gettitle.md +0 -15
  157. package/docs/api/player.playbackrate.goback.md +0 -15
  158. package/docs/api/player.playbackrate.highlightcurrentrate.md +0 -15
  159. package/docs/api/player.playbackrate.onfinishad.md +0 -15
  160. package/docs/api/player.playbackrate.onshowmenu.md +0 -15
  161. package/docs/api/player.playbackrate.onstartad.md +0 -15
  162. package/docs/api/player.playbackrate.onstop.md +0 -15
  163. package/docs/api/player.playbackrate.reload.md +0 -15
  164. package/docs/api/player.playbackrate.render.md +0 -15
  165. package/docs/api/player.playbackrate.supportedversion.md +0 -13
  166. package/docs/api/player.playbackrate.unbindevents.md +0 -15
  167. package/docs/api/player.sourcecontroller.version.md +0 -14
  168. package/docs/api/player.spinnerthreebounce.attributes.md +0 -14
  169. package/docs/api/player.spinnerthreebounce.name.md +0 -11
  170. package/docs/api/player.spinnerthreebounce.render.md +0 -15
  171. package/docs/api/player.spinnerthreebounce.supportedversion.md +0 -13
  172. package/docs/api/player.statistics.bindevents.md +0 -15
  173. package/docs/api/player.statistics.md +0 -141
  174. package/docs/api/player.statistics.name.md +0 -11
  175. package/docs/api/player.statistics.supportedversion.md +0 -13
  176. package/docs/api/player.subtitles.attributes.md +0 -14
  177. package/docs/api/player.subtitles.bindevents.md +0 -15
  178. package/docs/api/player.subtitles.buttonelement.md +0 -15
  179. package/docs/api/player.subtitles.events.md +0 -14
  180. package/docs/api/player.subtitles.levelelement.md +0 -51
  181. package/docs/api/player.subtitles.name.md +0 -11
  182. package/docs/api/player.subtitles.preselectedlanguage.md +0 -11
  183. package/docs/api/player.subtitles.reload.md +0 -15
  184. package/docs/api/player.subtitles.render.md +0 -15
  185. package/docs/api/player.subtitles.selectsubtitles.md +0 -15
  186. package/docs/api/player.subtitles.startlevelswitch.md +0 -15
  187. package/docs/api/player.subtitles.stoplevelswitch.md +0 -15
  188. package/docs/api/player.subtitles.supportedversion.md +0 -13
  189. package/docs/api/player.subtitles.template.md +0 -11
  190. package/docs/api/player.subtitles.templatestring.md +0 -11
  191. package/docs/api/player.subtitles.unbindevents.md +0 -15
  192. package/docs/api/player.subtitles.version.md +0 -11
  193. package/docs/api/player.volumefade.bindevents.md +0 -18
  194. package/docs/api/player.volumefade.unbindevents.md +0 -18
  195. package/src/plugins/statistics/Statistics.ts +0 -207
  196. /package/src/plugins/{statistics → telemetry}/Statistics copy.xts +0 -0
@@ -1,11 +1,14 @@
1
- import { UICorePlugin, Events, template, Core, Container } from '@clappr/core';
2
- import { reportError } from '@gcorevideo/utils';
3
- import Mousetrap from 'mousetrap';
4
-
5
- import { CLAPPR_VERSION } from '../../build.js';
6
- import { ClapprStatsEvents, Metrics as BaseMetrics } from '../clappr-stats/types.js';
7
- import { newMetrics as newBaseMetrics } from '../clappr-stats/utils.js';
8
- import Formatter from './formatter.js';
1
+ import { UICorePlugin, Events, template, Core, Container } from '@clappr/core'
2
+ import { reportError } from '@gcorevideo/utils'
3
+ import Mousetrap from 'mousetrap'
4
+
5
+ import { CLAPPR_VERSION } from '../../build.js'
6
+ import {
7
+ ClapprStatsEvents,
8
+ Metrics as BaseMetrics,
9
+ } from '../clappr-stats/types.js'
10
+ import { newMetrics as newBaseMetrics } from '../clappr-stats/utils.js'
11
+ import Formatter from './formatter.js'
9
12
  import {
10
13
  clearSpeedTestResults,
11
14
  configureSpeedTest,
@@ -13,105 +16,126 @@ import {
13
16
  initSpeedTest,
14
17
  startSpeedtest,
15
18
  stopSpeedtest,
16
- } from './speedtest/index.js';
17
- import { CustomMetrics } from './speedtest/types.js';
18
- import { ZeptoResult } from '../../utils/types.js';
19
-
20
- import '../../../assets/clappr-nerd-stats/clappr-nerd-stats.scss';
21
- import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs';
22
- import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs';
23
- import statsIcon from '../../../assets/icons/new/stats.svg';
24
- import { BottomGear, Events as BottomGearEvents } from '../bottom-gear/BottomGear.js';
25
- import { MediaControl } from '../media-control/MediaControl.js';
26
- import assert from 'assert';
19
+ } from './speedtest/index.js'
20
+ import { CustomMetrics } from './speedtest/types.js'
21
+ import { ZeptoResult } from '../../utils/types.js'
22
+
23
+ import '../../../assets/clappr-nerd-stats/clappr-nerd-stats.scss'
24
+ import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs'
25
+ import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs'
26
+ import statsIcon from '../../../assets/icons/new/stats.svg'
27
+ import { BottomGear, GearEvents } from '../bottom-gear/BottomGear.js'
28
+ import { MediaControl } from '../media-control/MediaControl.js'
29
+ import assert from 'assert'
27
30
 
28
31
  const qualityClasses = [
29
32
  'speedtest-quality-value-1',
30
33
  'speedtest-quality-value-2',
31
34
  'speedtest-quality-value-3',
32
35
  'speedtest-quality-value-4',
33
- 'speedtest-quality-value-5'
34
- ];
36
+ 'speedtest-quality-value-5',
37
+ ]
35
38
 
36
39
  const getDownloadQuality = (speedValue: number): number => {
37
40
  if (speedValue < 3) {
38
- return 1;
41
+ return 1
39
42
  } else if (speedValue < 7) {
40
- return 2;
43
+ return 2
41
44
  } else if (speedValue < 13) {
42
- return 3;
45
+ return 3
43
46
  } else if (speedValue < 25) {
44
- return 4;
47
+ return 4
45
48
  } else {
46
- return 5;
49
+ return 5
47
50
  }
48
- };
51
+ }
49
52
 
50
53
  const getPingQuality = (pingValue: number): number => {
51
54
  if (pingValue < 20) {
52
- return 5;
55
+ return 5
53
56
  } else if (pingValue < 50) {
54
- return 4;
57
+ return 4
55
58
  } else if (pingValue < 100) {
56
- return 3;
59
+ return 3
57
60
  } else if (pingValue < 150) {
58
- return 2;
61
+ return 2
59
62
  } else {
60
- return 1;
63
+ return 1
61
64
  }
62
- };
65
+ }
63
66
 
64
67
  const generateQualityHtml = (quality: number): string => {
65
- const html = [];
66
- const qualityClassName = qualityClasses[quality - 1];
68
+ const html = []
69
+ const qualityClassName = qualityClasses[quality - 1]
67
70
 
68
71
  for (let i = 0; i < qualityClasses.length; i++) {
69
72
  if (i < quality) {
70
- html.push(`<div class="speedtest-quality-content-item ${qualityClassName}"></div>`);
73
+ html.push(
74
+ `<div class="speedtest-quality-content-item ${qualityClassName}"></div>`,
75
+ )
71
76
  } else {
72
- html.push('<div class="speedtest-quality-content-item"></div>');
77
+ html.push('<div class="speedtest-quality-content-item"></div>')
73
78
  }
74
79
  }
75
80
 
76
- return html.join('');
77
- };
81
+ return html.join('')
82
+ }
78
83
 
79
- const drawSummary = (customMetrics: CustomMetrics, vodContainer: ZeptoResult, liveContainer: ZeptoResult) => {
80
- const { connectionSpeed, ping } = customMetrics;
84
+ const drawSummary = (
85
+ customMetrics: CustomMetrics,
86
+ vodContainer: ZeptoResult,
87
+ liveContainer: ZeptoResult,
88
+ ) => {
89
+ const { connectionSpeed, ping } = customMetrics
81
90
 
82
91
  if (!connectionSpeed || !ping) {
83
- return;
92
+ return
84
93
  }
85
- const downloadQuality = getDownloadQuality(connectionSpeed);
86
- const pingQuality = getPingQuality(ping);
87
- const liveQuality = Math.min(downloadQuality, pingQuality);
88
- const vodHtml = generateQualityHtml(downloadQuality);
89
- const liveHtml = generateQualityHtml(liveQuality);
90
-
91
- vodContainer.html(vodHtml);
92
- liveContainer.html(liveHtml);
93
- };
94
+ const downloadQuality = getDownloadQuality(connectionSpeed)
95
+ const pingQuality = getPingQuality(ping)
96
+ const liveQuality = Math.min(downloadQuality, pingQuality)
97
+ const vodHtml = generateQualityHtml(downloadQuality)
98
+ const liveHtml = generateQualityHtml(liveQuality)
99
+
100
+ vodContainer.html(vodHtml)
101
+ liveContainer.html(liveHtml)
102
+ }
94
103
 
95
- type IconPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
104
+ type IconPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
96
105
 
97
106
  type Metrics = BaseMetrics & {
98
107
  general: {
99
- displayResolution?: string;
100
- volume?: number;
101
- },
108
+ displayResolution?: string
109
+ volume?: number
110
+ }
102
111
  custom: CustomMetrics & {
103
- vodQuality?: string;
104
- liveQuality?: string;
105
- };
112
+ vodQuality?: string
113
+ liveQuality?: string
114
+ }
106
115
  }
107
116
 
108
117
  // const T = 'plugins.clappr_nerd_stats';
109
118
 
110
119
  /**
120
+ * Displays useful network-related statistics.
111
121
  * @beta
122
+ *
123
+ * @remarks
124
+ * Depends on:
125
+ *
126
+ * - {@link MediaControl}
127
+ *
128
+ * - {@link BottomGear}
129
+ *
130
+ * - {@link ClapprStats}
131
+ *
132
+ * The plugin is rendered as an item in the gear menu.
133
+ *
134
+ * When clicked, it shows an overlay window with the information about the network speed, latency, etc,
135
+ * and recommended quality level.
112
136
  */
113
137
  export class ClapprNerdStats extends UICorePlugin {
114
- private container: Container | null = null;
138
+ private container: Container | null = null
115
139
 
116
140
  private customMetrics: CustomMetrics = {
117
141
  connectionSpeed: 0,
@@ -119,238 +143,281 @@ export class ClapprNerdStats extends UICorePlugin {
119
143
  jitter: 0,
120
144
  }
121
145
 
122
- private metrics: Metrics = newMetrics();
146
+ private metrics: Metrics = newMetrics()
123
147
 
124
- private showing = false;
148
+ private showing = false
125
149
 
126
- private shortcut: string[];
150
+ private shortcut: string[]
127
151
 
128
- private iconPosition: IconPosition;
152
+ private iconPosition: IconPosition
129
153
 
154
+ /**
155
+ * @internal
156
+ */
130
157
  get name() {
131
- return 'media_control_nerd_stats';
158
+ return 'nerd_stats'
132
159
  }
133
160
 
161
+ /**
162
+ * @internal
163
+ */
134
164
  get supportedVersion() {
135
- return { min: CLAPPR_VERSION };
165
+ return { min: CLAPPR_VERSION }
136
166
  }
137
167
 
138
- get template() {
139
- return template(pluginHtml);
140
- }
168
+ private static readonly template = template(pluginHtml)
141
169
 
170
+ /**
171
+ * @internal
172
+ */
142
173
  override get attributes() {
143
174
  return {
144
175
  'data-clappr-nerd-stats': '',
145
- 'class': 'clappr-nerd-stats'
146
- };
176
+ class: 'clappr-nerd-stats',
177
+ }
147
178
  }
148
179
 
180
+ /**
181
+ * @internal
182
+ */
149
183
  override get events() {
150
184
  return {
151
185
  'click [data-show-stats-button]': 'showOrHide',
152
186
  'click [data-close-button]': 'hide',
153
187
  'click [data-refresh-button]': 'refreshSpeedTest',
154
- };
188
+ }
155
189
  }
156
190
 
157
- get statsBoxElem() {
158
- return '.clappr-nerd-stats[data-clappr-nerd-stats] .stats-box';
191
+ private get statsBoxElem() {
192
+ return '.clappr-nerd-stats[data-clappr-nerd-stats] .stats-box'
159
193
  }
160
194
 
161
- get statsBoxWidthThreshold() {
162
- return 720;
195
+ private get statsBoxWidthThreshold() {
196
+ return 720
163
197
  }
164
198
 
165
- get playerWidth() {
166
- return this.core.$el.width();
199
+ private get playerWidth() {
200
+ return this.core.$el.width()
167
201
  }
168
202
 
169
- get playerHeight() {
170
- return this.core.$el.height();
203
+ private get playerHeight() {
204
+ return this.core.$el.height()
171
205
  }
172
206
 
173
207
  constructor(core: Core) {
174
- super(core);
175
- this.shortcut = core.options.clapprNerdStats?.shortcut ?? ['command+shift+s', 'ctrl+shift+s'];
176
- this.iconPosition = core.options.clapprNerdStats?.iconPosition ?? 'bottom-right';
208
+ super(core)
209
+ this.shortcut = core.options.clapprNerdStats?.shortcut ?? [
210
+ 'command+shift+s',
211
+ 'ctrl+shift+s',
212
+ ]
213
+ this.iconPosition =
214
+ core.options.clapprNerdStats?.iconPosition ?? 'bottom-right'
177
215
  this.customMetrics = {
178
216
  connectionSpeed: 0,
179
217
  ping: 0,
180
218
  jitter: 0,
181
- };
182
- configureSpeedTest(core.options.clapprNerdStats?.speedTestServers ?? []);
219
+ }
220
+ configureSpeedTest(core.options.clapprNerdStats?.speedTestServers ?? [])
183
221
  }
184
222
 
223
+ /**
224
+ * @internal
225
+ */
185
226
  override bindEvents() {
186
- const mediaControl = this.core.getPlugin('media_control') as MediaControl;
187
- assert(mediaControl, 'media_control plugin is required');
188
- this.listenToOnce(this.core, Events.CORE_READY, this.init);
189
- this.listenTo(mediaControl, BottomGearEvents.MEDIACONTROL_GEAR_RENDERED, this.addToBottomGear);
227
+ const mediaControl = this.core.getPlugin('media_control') as MediaControl
228
+ assert(mediaControl, 'media_control plugin is required')
229
+ this.listenToOnce(this.core, Events.CORE_READY, this.init)
230
+ this.listenTo(
231
+ mediaControl,
232
+ GearEvents.MEDIACONTROL_GEAR_RENDERED,
233
+ this.addToBottomGear,
234
+ )
190
235
  }
191
236
 
192
237
  private init() {
193
- this.container = this.core.activeContainer;
194
- const clapprStats = this.container?.getPlugin('clappr_stats');
238
+ this.container = this.core.activeContainer
239
+ const clapprStats = this.container?.getPlugin('clappr_stats')
195
240
 
196
241
  if (!clapprStats) {
197
242
  reportError({
198
243
  message: 'clappr_stats plugin is not available',
199
- });
200
- console.error('clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
201
- 'For more info, visit: https://github.com/clappr/clappr-stats.');
202
- this.disable();
244
+ })
245
+ console.error(
246
+ 'clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
247
+ 'For more info, visit: https://github.com/clappr/clappr-stats.',
248
+ )
249
+ this.disable()
203
250
  } else {
204
- Mousetrap.bind(this.shortcut, () => this.toggle());
205
- this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize);
251
+ Mousetrap.bind(this.shortcut, () => this.toggle())
252
+ this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize)
206
253
  // TODO: fix
207
- this.listenTo(clapprStats, ClapprStatsEvents.REPORT_EVENT, this.updateMetrics);
208
- clapprStats.setUpdateMetrics(this.updateMetrics.bind(this));
209
- this.updateMetrics(clapprStats.exportMetrics());
210
- this.render();
254
+ this.listenTo(
255
+ clapprStats,
256
+ ClapprStatsEvents.REPORT_EVENT,
257
+ this.updateMetrics,
258
+ )
259
+ clapprStats.setUpdateMetrics(this.updateMetrics.bind(this))
260
+ this.updateMetrics(clapprStats.exportMetrics())
261
+ this.render()
211
262
  }
212
263
  }
213
264
 
214
265
  private toggle() {
215
266
  if (this.showing) {
216
- this.hide();
267
+ this.hide()
217
268
  } else {
218
- this.show();
269
+ this.show()
219
270
  }
220
271
  }
221
272
 
222
273
  private show() {
223
- this.core.$el.find(this.statsBoxElem).show();
224
- this.showing = true;
225
-
226
- this.refreshSpeedTest();
227
- initSpeedTest(this.customMetrics).then(() => {
228
- startSpeedtest();
229
- }).catch(e => {
230
- reportError(e);
231
- this.disable();
232
- })
274
+ this.core.$el.find(this.statsBoxElem).show()
275
+ this.showing = true
276
+
277
+ this.refreshSpeedTest()
278
+ initSpeedTest(this.customMetrics)
279
+ .then(() => {
280
+ startSpeedtest()
281
+ })
282
+ .catch((e) => {
283
+ reportError(e)
284
+ this.disable()
285
+ })
233
286
  }
234
287
 
235
288
  private hide() {
236
- this.core.$el.find(this.statsBoxElem).hide();
237
- this.showing = false;
238
- stopSpeedtest();
289
+ this.core.$el.find(this.statsBoxElem).hide()
290
+ this.showing = false
291
+ stopSpeedtest()
239
292
  }
240
293
 
241
294
  private onPlayerResize() {
242
- this.setStatsBoxSize();
295
+ this.setStatsBoxSize()
243
296
  }
244
297
 
245
298
  private addGeneralMetrics() {
246
299
  this.metrics.general = {
247
- displayResolution: (this.playerWidth + 'x' + this.playerHeight),
248
- volume: this.container?.volume
249
- };
300
+ displayResolution: this.playerWidth + 'x' + this.playerHeight,
301
+ volume: this.container?.volume,
302
+ }
250
303
  }
251
304
 
252
305
  private addCustomMetrics() {
253
- this.metrics.custom = this.customMetrics;
254
- const videoQualityNames = ['SD (480p)', 'HD (720p)', 'Full HD (1080p)', '2K (1440p)', '4K (2160p)'];
255
- const { connectionSpeed, ping } = this.customMetrics;
306
+ this.metrics.custom = this.customMetrics
307
+ const videoQualityNames = [
308
+ 'SD (480p)',
309
+ 'HD (720p)',
310
+ 'Full HD (1080p)',
311
+ '2K (1440p)',
312
+ '4K (2160p)',
313
+ ]
314
+ const { connectionSpeed, ping } = this.customMetrics
256
315
 
257
316
  if (!connectionSpeed || !ping) {
258
- const calculatingText = 'Calculating... Please wait.';
317
+ const calculatingText = 'Calculating... Please wait.'
259
318
 
260
- this.metrics.custom.vodQuality = calculatingText;
261
- this.metrics.custom.liveQuality = calculatingText;
319
+ this.metrics.custom.vodQuality = calculatingText
320
+ this.metrics.custom.liveQuality = calculatingText
262
321
 
263
- return;
322
+ return
264
323
  }
265
- const downloadQuality = getDownloadQuality(connectionSpeed);
266
- const pingQuality = getPingQuality(ping);
267
- const liveQuality = Math.min(downloadQuality, pingQuality);
324
+ const downloadQuality = getDownloadQuality(connectionSpeed)
325
+ const pingQuality = getPingQuality(ping)
326
+ const liveQuality = Math.min(downloadQuality, pingQuality)
268
327
 
269
- const prefix = 'Optimal for ';
328
+ const prefix = 'Optimal for '
270
329
 
271
- this.metrics.custom.vodQuality = prefix + videoQualityNames[downloadQuality - 1];
272
- this.metrics.custom.liveQuality = prefix + videoQualityNames[liveQuality - 1];
330
+ this.metrics.custom.vodQuality =
331
+ prefix + videoQualityNames[downloadQuality - 1]
332
+ this.metrics.custom.liveQuality =
333
+ prefix + videoQualityNames[liveQuality - 1]
273
334
  }
274
335
 
275
336
  private updateMetrics(metrics: BaseMetrics) {
276
- Object.assign(this.metrics, metrics);
277
- this.addGeneralMetrics();
278
- this.addCustomMetrics();
279
-
280
- const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop();
281
-
282
- this.$el.html(this.template({
283
- metrics: Formatter.format(this.metrics),
284
- iconPosition: this.iconPosition
285
- }));
286
- this.setStatsBoxSize();
287
- drawSpeedTestResults();
337
+ Object.assign(this.metrics, metrics)
338
+ this.addGeneralMetrics()
339
+ this.addCustomMetrics()
340
+
341
+ const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop()
342
+
343
+ this.$el.html(
344
+ ClapprNerdStats.template({
345
+ metrics: Formatter.format(this.metrics),
346
+ iconPosition: this.iconPosition,
347
+ }),
348
+ )
349
+ this.setStatsBoxSize()
350
+ drawSpeedTestResults()
288
351
  drawSummary(
289
352
  this.metrics?.custom,
290
353
  this.$el.find('.speedtest-quality-content[data-streaming-type="vod"]'),
291
- this.$el.find('.speedtest-quality-content[data-streaming-type="live"]')
292
- );
354
+ this.$el.find('.speedtest-quality-content[data-streaming-type="live"]'),
355
+ )
293
356
 
294
- this.core.$el.find(this.statsBoxElem).scrollTop(scrollTop);
357
+ this.core.$el.find(this.statsBoxElem).scrollTop(scrollTop)
295
358
 
296
359
  if (!this.showing) {
297
- this.hide();
360
+ this.hide()
298
361
  }
299
362
  }
300
363
 
301
364
  private setStatsBoxSize() {
302
365
  if (this.playerWidth >= this.statsBoxWidthThreshold) {
303
- this.$el.find(this.statsBoxElem).addClass('wide');
304
- this.$el.find(this.statsBoxElem).removeClass('narrow');
366
+ this.$el.find(this.statsBoxElem).addClass('wide')
367
+ this.$el.find(this.statsBoxElem).removeClass('narrow')
305
368
  } else {
306
- this.$el.find(this.statsBoxElem).removeClass('wide');
307
- this.$el.find(this.statsBoxElem).addClass('narrow');
369
+ this.$el.find(this.statsBoxElem).removeClass('wide')
370
+ this.$el.find(this.statsBoxElem).addClass('narrow')
308
371
  }
309
372
  }
310
373
 
374
+ /**
375
+ * @internal
376
+ */
311
377
  override render() {
312
- this.core.$el.append(this.$el[0]);
313
- this.hide();
378
+ // TODO append to the container
379
+ this.core.$el.append(this.$el[0])
380
+ this.hide()
314
381
 
315
- return this;
382
+ return this
316
383
  }
317
384
 
318
385
  private addToBottomGear() {
319
- const gear = this.core.getPlugin('media_control_gear') as BottomGear;
386
+ const gear = this.core.getPlugin('bottom_gear') as BottomGear
320
387
  const $el = gear.getElement('nerd')
321
388
  $el.html(buttonHtml)
322
- const $button = $el.find('.nerd-button');
389
+ const $button = $el.find('.nerd-button')
323
390
 
324
- $button.find('.stats-icon').html(statsIcon);
391
+ $button.find('.stats-icon').html(statsIcon)
325
392
 
326
393
  $button.on('click', (e: MouseEvent) => {
327
- e.stopPropagation();
328
- this.toggle();
329
- });
394
+ e.stopPropagation()
395
+ this.toggle()
396
+ })
330
397
  }
331
398
 
332
399
  private clearCustomMetrics() {
333
- const clapprStats = this.container?.getPlugin('clappr_stats');
400
+ const clapprStats = this.container?.getPlugin('clappr_stats')
334
401
 
335
- this.customMetrics.connectionSpeed = 0;
336
- this.customMetrics.ping = 0;
337
- this.customMetrics.jitter = 0;
402
+ this.customMetrics.connectionSpeed = 0
403
+ this.customMetrics.ping = 0
404
+ this.customMetrics.jitter = 0
338
405
 
339
406
  if (clapprStats) {
340
- this.updateMetrics(clapprStats.exportMetrics());
407
+ this.updateMetrics(clapprStats.exportMetrics())
341
408
  }
342
409
  }
343
410
 
344
411
  private refreshSpeedTest() {
345
- stopSpeedtest();
412
+ stopSpeedtest()
346
413
  setTimeout(() => {
347
- this.clearCustomMetrics();
348
- clearSpeedTestResults();
349
- drawSpeedTestResults();
350
- }, 200);
414
+ this.clearCustomMetrics()
415
+ clearSpeedTestResults()
416
+ drawSpeedTestResults()
417
+ }, 200)
351
418
  setTimeout(() => {
352
- startSpeedtest();
353
- }, 800);
419
+ startSpeedtest()
420
+ }, 800)
354
421
  }
355
422
  }
356
423
 
@@ -11,8 +11,11 @@ import '../../../assets/dvr-controls/dvr_controls.scss';
11
11
  * @beta
12
12
  *
13
13
  * @remarks
14
- * The plugin is rendered in the {@link MediaControl | media control} UI.
15
- * It renders the live stream indicator and the DVR seek bar if DVR is enabled.
14
+ * Depends on:
15
+ *
16
+ * - {@link MediaControl | media_control}
17
+ *
18
+ * The plugin renders the live stream indicator and the DVR seek bar, if DVR is enabled, in the media control UI.
16
19
  */
17
20
  export class DvrControls extends UICorePlugin {
18
21
  private static readonly template = template(dvrHTML);
@@ -29,6 +29,11 @@ type PresentationalError = {
29
29
 
30
30
  const T = 'plugins.error_screen'
31
31
 
32
+ /**
33
+ * Displays a descriptive error in the overlay on top of the player.
34
+ * @beta
35
+ * TODO
36
+ */
32
37
  export class ErrorScreen extends UICorePlugin {
33
38
  private _retry = 0;
34
39
 
@@ -31,12 +31,11 @@ export * from "./poster/Poster.js";
31
31
  export * from "./seek-time/SeekTime.js";
32
32
  export * from "./share/Share.js";
33
33
  export * from "./skip-time/SkipTime.js";
34
+ export * from "./source-controller/SourceController.js";
34
35
  export * from "./spinner-three-bounce/SpinnerThreeBounce.js";
35
- export * from "./statistics/Statistics.js";
36
36
  export * from "./subtitles/Subtitles.js";
37
+ export * from "./telemetry/Telemetry.js";
37
38
  export * from "./thumbnails/Thumbnails.js";
38
- export { setTracer} from "@gcorevideo/utils";
39
- export * from "./source-controller/SourceController.js";
40
39
  // _ vast-ads
41
40
  // _ video360
42
41
  export * from "./volume-fade/VolumeFade.js";