@gcorevideo/player 2.28.19 → 2.28.21

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 (37) hide show
  1. package/assets/bottom-gear/gear.scss +2 -2
  2. package/assets/icons/new/arrow-right.svg +1 -1
  3. package/assets/icons/new/hd.svg +1 -1
  4. package/assets/icons/new/speed.svg +1 -1
  5. package/dist/core.js +1 -1
  6. package/dist/index.css +303 -303
  7. package/dist/index.embed.js +118 -37
  8. package/dist/index.js +118 -38
  9. package/lib/plugins/audio-selector/AudioTracks.d.ts +2 -0
  10. package/lib/plugins/audio-selector/AudioTracks.d.ts.map +1 -1
  11. package/lib/plugins/audio-selector/AudioTracks.js +11 -0
  12. package/lib/plugins/bottom-gear/BottomGear.d.ts +2 -0
  13. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  14. package/lib/plugins/bottom-gear/BottomGear.js +11 -0
  15. package/lib/plugins/level-selector/QualityLevels.d.ts.map +1 -1
  16. package/lib/plugins/level-selector/QualityLevels.js +4 -0
  17. package/lib/plugins/media-control/MediaControl.d.ts +10 -0
  18. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  19. package/lib/plugins/media-control/MediaControl.js +21 -22
  20. package/lib/plugins/subtitles/ClosedCaptions.d.ts +3 -0
  21. package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
  22. package/lib/plugins/subtitles/ClosedCaptions.js +30 -11
  23. package/lib/testUtils.d.ts.map +1 -1
  24. package/lib/testUtils.js +2 -0
  25. package/lib/utils/clickaway.d.ts +15 -0
  26. package/lib/utils/clickaway.d.ts.map +1 -0
  27. package/lib/utils/clickaway.js +40 -0
  28. package/package.json +1 -1
  29. package/src/plugins/audio-selector/AudioTracks.ts +15 -1
  30. package/src/plugins/bottom-gear/BottomGear.ts +13 -0
  31. package/src/plugins/level-selector/QualityLevels.ts +4 -0
  32. package/src/plugins/media-control/MediaControl.ts +21 -24
  33. package/src/plugins/subtitles/ClosedCaptions.ts +34 -12
  34. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +9 -3
  35. package/src/testUtils.ts +2 -0
  36. package/src/utils/clickaway.ts +43 -0
  37. package/tsconfig.tsbuildinfo +1 -1
package/src/testUtils.ts CHANGED
@@ -137,6 +137,8 @@ export function createMockMediaControl(core: any) {
137
137
  mediaControl.getAvailablePopupHeight = vi.fn().mockReturnValue(286)
138
138
  // @ts-ignore
139
139
  mediaControl.toggleElement = vi.fn()
140
+ // @ts-ignore
141
+ mediaControl.setKeepVisible = vi.fn()
140
142
  vi.spyOn(mediaControl, 'trigger')
141
143
  core.$el.append(mediaControl.$el)
142
144
  return mediaControl
@@ -0,0 +1,43 @@
1
+ import { Browser } from '@clappr/core'
2
+
3
+ /**
4
+ *
5
+ * @param {() => void} callback - The callback to call when the user clicks away from the element
6
+ * @returns {(HTMLElement | null) => void}
7
+ */
8
+ export function clickaway(callback: () => void) {
9
+ let handler = (event: MouseEvent | TouchEvent) => { }
10
+
11
+ return (node: HTMLElement | null) => {
12
+ window.removeEventListener('click', handler)
13
+ if (!node) {
14
+ return
15
+ }
16
+ handler = (event: MouseEvent | TouchEvent) => {
17
+ if (!node.contains(event.target as Node)) {
18
+ window.removeEventListener('click', handler)
19
+ callback()
20
+ }
21
+ }
22
+ window.addEventListener('click', handler)
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Sets up a clickaway handler for the media control on mobile devices.
28
+ * The handler is deferred to ensure it is called after the next event loop tick.
29
+ *
30
+ * @param {() => void} callback - The callback to call when the user clicks away from the media control
31
+ * @returns {(HTMLElement | null) => void}
32
+ */
33
+ export function mediaControlClickaway(callback: () => void) {
34
+ if (!Browser.isMobile) {
35
+ return () => { }
36
+ }
37
+ const cw = clickaway(callback)
38
+ return (node: HTMLElement | null) => {
39
+ setTimeout(() => {
40
+ cw(node)
41
+ }, 0)
42
+ }
43
+ }