@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.
- package/assets/bottom-gear/gear.scss +2 -2
- package/assets/icons/new/arrow-right.svg +1 -1
- package/assets/icons/new/hd.svg +1 -1
- package/assets/icons/new/speed.svg +1 -1
- package/dist/core.js +1 -1
- package/dist/index.css +303 -303
- package/dist/index.embed.js +118 -37
- package/dist/index.js +118 -38
- package/lib/plugins/audio-selector/AudioTracks.d.ts +2 -0
- package/lib/plugins/audio-selector/AudioTracks.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioTracks.js +11 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts +2 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +11 -0
- package/lib/plugins/level-selector/QualityLevels.d.ts.map +1 -1
- package/lib/plugins/level-selector/QualityLevels.js +4 -0
- package/lib/plugins/media-control/MediaControl.d.ts +10 -0
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +21 -22
- package/lib/plugins/subtitles/ClosedCaptions.d.ts +3 -0
- package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.js +30 -11
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +2 -0
- package/lib/utils/clickaway.d.ts +15 -0
- package/lib/utils/clickaway.d.ts.map +1 -0
- package/lib/utils/clickaway.js +40 -0
- package/package.json +1 -1
- package/src/plugins/audio-selector/AudioTracks.ts +15 -1
- package/src/plugins/bottom-gear/BottomGear.ts +13 -0
- package/src/plugins/level-selector/QualityLevels.ts +4 -0
- package/src/plugins/media-control/MediaControl.ts +21 -24
- package/src/plugins/subtitles/ClosedCaptions.ts +34 -12
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +9 -3
- package/src/testUtils.ts +2 -0
- package/src/utils/clickaway.ts +43 -0
- 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
|
+
}
|