@gcorevideo/player 2.22.16 → 2.22.17
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/dist/core.js +6 -8
- package/dist/index.css +1338 -1338
- package/dist/index.js +361 -439
- package/dist/player.d.ts +216 -159
- package/dist/plugins/index.css +1463 -1463
- package/dist/plugins/index.js +354 -427
- package/docs/api/player.clapprstats.exportmetrics.md +1 -1
- package/docs/api/player.clapprstats.md +5 -15
- package/docs/api/player.clapprstatssettings.md +13 -0
- package/docs/api/player.clips.destroy.md +18 -0
- package/docs/api/player.clips.disable.md +18 -0
- package/docs/api/player.clips.enable.md +18 -0
- package/docs/api/player.clips.md +170 -0
- package/docs/api/player.clips.render.md +18 -0
- package/docs/api/player.clips.supportedversion.md +16 -0
- package/docs/api/player.clips.version.md +14 -0
- package/docs/api/player.clipspluginsettings.md +2 -2
- package/docs/api/player.clipspluginsettings.text.md +1 -1
- package/docs/api/player.md +27 -18
- package/docs/api/player.mediacontrol.md +1 -1
- package/docs/api/{player.mediacontrol.getelement.md → player.mediacontrol.mount.md} +20 -7
- package/docs/api/player.mediacontrolleftelement.md +1 -1
- package/docs/api/{player.clapprnerdstats._constructor_.md → player.nerdstats._constructor_.md} +3 -3
- package/docs/api/{player.clapprnerdstats.md → player.nerdstats.md} +5 -5
- package/docs/api/player.qualitylevel.height.md +1 -1
- package/docs/api/player.qualitylevel.level.md +1 -1
- package/docs/api/player.qualitylevel.md +4 -4
- package/docs/api/player.qualitylevel.width.md +1 -1
- package/docs/api/player.timeposition.current.md +1 -1
- package/docs/api/player.timeposition.md +2 -2
- package/docs/api/player.timeposition.total.md +1 -1
- package/docs/api/player.timeprogress.md +6 -4
- package/docs/api/player.timevalue.md +1 -1
- package/lib/index.plugins.d.ts +2 -1
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +2 -1
- package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.js +5 -7
- package/lib/playback.types.d.ts +22 -9
- package/lib/playback.types.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +4 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +20 -23
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +83 -0
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/NerdStats.js +339 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +27 -32
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/ClapprStats.js +94 -202
- package/lib/plugins/clappr-stats/types.d.ts +65 -24
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/types.js +37 -2
- package/lib/plugins/clappr-stats/utils.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/utils.js +1 -2
- package/lib/testUtils.d.ts +2 -1
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +3 -2
- package/package.json +1 -1
- package/src/index.plugins.ts +2 -1
- package/src/playback/dash-playback/DashPlayback.ts +5 -8
- package/src/playback.types.ts +23 -8
- package/src/plugins/clappr-nerd-stats/{ClapprNerdStats.ts → NerdStats.ts} +25 -30
- package/src/plugins/clappr-stats/ClapprStats.ts +242 -306
- package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +133 -0
- package/src/plugins/clappr-stats/types.ts +72 -25
- package/src/plugins/clappr-stats/utils.ts +1 -2
- package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +3 -4
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -0
- package/src/testUtils.ts +3 -2
- package/temp/player.api.json +311 -159
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.clapprstats.setupdatemetrics.md +0 -56
- package/docs/api/player.clipsplugin.gettext.md +0 -58
- package/docs/api/player.clipsplugin.md +0 -59
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { Events as CoreEvents } from '@clappr/core'
|
|
3
|
+
import FakeTimers from '@sinonjs/fake-timers'
|
|
4
|
+
|
|
5
|
+
import { ClapprStats } from '../ClapprStats'
|
|
6
|
+
import { createMockCore } from '../../../testUtils'
|
|
7
|
+
import { Chronograph, ClapprStatsEvents, Counter } from '../types'
|
|
8
|
+
|
|
9
|
+
describe('ClapprStats', () => {
|
|
10
|
+
let core: any
|
|
11
|
+
let stats: ClapprStats
|
|
12
|
+
let onReport: any
|
|
13
|
+
let clock: FakeTimers.InstalledClock
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
core = createMockCore()
|
|
16
|
+
stats = new ClapprStats(core.activeContainer)
|
|
17
|
+
clock = FakeTimers.install()
|
|
18
|
+
})
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
clock.uninstall()
|
|
21
|
+
})
|
|
22
|
+
describe('time measurements', () => {
|
|
23
|
+
describe('startup', () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
vi.spyOn(performance, 'now').mockReturnValue(100)
|
|
26
|
+
core.activeContainer.playback.emit(CoreEvents.PLAYBACK_PLAY_INTENT)
|
|
27
|
+
vi.spyOn(performance, 'now').mockReturnValue(255)
|
|
28
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
29
|
+
})
|
|
30
|
+
it('should measure', () => {
|
|
31
|
+
const metrics = stats.exportMetrics()
|
|
32
|
+
expect(metrics.chrono[Chronograph.Startup]).toBe(155)
|
|
33
|
+
// expect(metrics.times[Chronograph.Session]).toBe(155)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
describe('watch', () => {
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
vi.spyOn(performance, 'now').mockReturnValue(100)
|
|
39
|
+
core.activeContainer.playback.emit(CoreEvents.PLAYBACK_PLAY_INTENT)
|
|
40
|
+
vi.spyOn(performance, 'now').mockReturnValue(150)
|
|
41
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
42
|
+
vi.spyOn(performance, 'now').mockReturnValue(3000)
|
|
43
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PAUSE)
|
|
44
|
+
vi.spyOn(performance, 'now').mockReturnValue(4900)
|
|
45
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
46
|
+
vi.spyOn(performance, 'now').mockReturnValue(5900)
|
|
47
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PAUSE)
|
|
48
|
+
vi.spyOn(performance, 'now').mockReturnValue(6900)
|
|
49
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
50
|
+
})
|
|
51
|
+
it('should measure cumulative play and pause durations', () => {
|
|
52
|
+
const metrics = stats.exportMetrics()
|
|
53
|
+
expect(metrics.chrono[Chronograph.Watch]).toBe(3850)
|
|
54
|
+
expect(metrics.chrono[Chronograph.Pause]).toBe(2900)
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
describe('buffering', () => {
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
vi.spyOn(performance, 'now').mockReturnValue(100)
|
|
60
|
+
core.activeContainer.playback.emit(CoreEvents.PLAYBACK_PLAY_INTENT)
|
|
61
|
+
vi.spyOn(performance, 'now').mockReturnValue(150)
|
|
62
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
63
|
+
vi.spyOn(performance, 'now').mockReturnValue(250)
|
|
64
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_STATE_BUFFERING)
|
|
65
|
+
vi.spyOn(performance, 'now').mockReturnValue(350)
|
|
66
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_STATE_BUFFERFULL)
|
|
67
|
+
vi.spyOn(performance, 'now').mockReturnValue(450)
|
|
68
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_STATE_BUFFERING)
|
|
69
|
+
vi.spyOn(performance, 'now').mockReturnValue(550)
|
|
70
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_STATE_BUFFERFULL)
|
|
71
|
+
})
|
|
72
|
+
it('should measure cumulative buffering durations', () => {
|
|
73
|
+
const metrics = stats.exportMetrics()
|
|
74
|
+
expect(metrics.chrono[Chronograph.Buffering]).toBe(200)
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
describe('session', () => {
|
|
78
|
+
beforeEach(() => {
|
|
79
|
+
onReport = vi.fn()
|
|
80
|
+
stats.on(ClapprStatsEvents.REPORT, onReport, null)
|
|
81
|
+
vi.spyOn(performance, 'now').mockReturnValue(100)
|
|
82
|
+
core.activeContainer.playback.emit(CoreEvents.PLAYBACK_PLAY_INTENT)
|
|
83
|
+
vi.spyOn(performance, 'now').mockReturnValue(200)
|
|
84
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
85
|
+
vi.spyOn(performance, 'now').mockReturnValue(60300)
|
|
86
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_STOP)
|
|
87
|
+
})
|
|
88
|
+
it('should measure', () => {
|
|
89
|
+
expect(onReport).toHaveBeenCalledWith(expect.objectContaining({
|
|
90
|
+
chrono: expect.objectContaining({
|
|
91
|
+
[Chronograph.Session]: 60200,
|
|
92
|
+
}),
|
|
93
|
+
}))
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
describe('fps measurements', () => {
|
|
98
|
+
beforeEach(async () => {
|
|
99
|
+
onReport = vi.fn()
|
|
100
|
+
core.activePlayback.name = 'html5_video'
|
|
101
|
+
stats.on(ClapprStatsEvents.REPORT, onReport, null)
|
|
102
|
+
vi.spyOn(performance, 'now').mockReturnValue(100)
|
|
103
|
+
core.activeContainer.playback.emit(CoreEvents.PLAYBACK_PLAY_INTENT)
|
|
104
|
+
vi.spyOn(performance, 'now').mockReturnValue(200)
|
|
105
|
+
vi.spyOn(performance, 'now').mockReturnValue(200)
|
|
106
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_PLAY)
|
|
107
|
+
core.activeContainer.playback.el.webkitDecodedFrameCount = 126
|
|
108
|
+
core.activeContainer.playback.el.webkitDroppedFrameCount = 3
|
|
109
|
+
vi.spyOn(performance, 'now').mockReturnValue(5225)
|
|
110
|
+
await clock.tickAsync(5000)
|
|
111
|
+
core.activeContainer.playback.el.webkitDecodedFrameCount = 275
|
|
112
|
+
core.activeContainer.playback.el.webkitDroppedFrameCount = 4
|
|
113
|
+
vi.spyOn(performance, 'now').mockReturnValue(10225)
|
|
114
|
+
core.activeContainer.trigger(CoreEvents.CONTAINER_STOP)
|
|
115
|
+
})
|
|
116
|
+
it('should measure fps', () => {
|
|
117
|
+
expect(onReport).toHaveBeenNthCalledWith(1, expect.objectContaining({
|
|
118
|
+
counters: expect.objectContaining({
|
|
119
|
+
[Counter.DecodedFrames]: 126,
|
|
120
|
+
[Counter.DroppedFrames]: 3,
|
|
121
|
+
[Counter.Fps]: expect.closeTo(25, 0),
|
|
122
|
+
}),
|
|
123
|
+
}))
|
|
124
|
+
expect(onReport).toHaveBeenNthCalledWith(2, expect.objectContaining({
|
|
125
|
+
counters: expect.objectContaining({
|
|
126
|
+
[Counter.DecodedFrames]: 275,
|
|
127
|
+
[Counter.DroppedFrames]: 4,
|
|
128
|
+
[Counter.Fps]: expect.closeTo(30, 0),
|
|
129
|
+
}),
|
|
130
|
+
}))
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
})
|
|
@@ -1,28 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
*/
|
|
4
|
+
export enum Chronograph {
|
|
5
|
+
Startup = 'startup',
|
|
6
|
+
Watch = 'watch',
|
|
7
|
+
Pause = 'pause',
|
|
8
|
+
Buffering = 'buffering',
|
|
9
|
+
Session = 'session',
|
|
10
|
+
// Latency = 'latency',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export enum Counter {
|
|
17
|
+
Play = 'play',
|
|
18
|
+
Pause = 'pause',
|
|
19
|
+
Error = 'error',
|
|
20
|
+
Buffering = 'buffering',
|
|
21
|
+
DecodedFrames = 'decodedFrames',
|
|
22
|
+
DroppedFrames = 'droppedFrames',
|
|
23
|
+
Fps = 'fps',
|
|
24
|
+
ChangeLevel = 'changeLevel',
|
|
25
|
+
Seek = 'seek',
|
|
26
|
+
Fullscreen = 'fullscreen',
|
|
27
|
+
DvrUsage = 'dvrUsage',
|
|
28
|
+
}
|
|
1
29
|
|
|
2
30
|
/**
|
|
3
31
|
* @beta
|
|
4
32
|
*/
|
|
5
33
|
export type Metrics = {
|
|
34
|
+
/**
|
|
35
|
+
* Events count counters
|
|
36
|
+
*/
|
|
6
37
|
counters: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
[Counter.Play]: number;
|
|
42
|
+
[Counter.Pause]: number;
|
|
43
|
+
[Counter.Error]: number;
|
|
44
|
+
[Counter.Buffering]: number;
|
|
45
|
+
[Counter.DecodedFrames]: number;
|
|
46
|
+
[Counter.DroppedFrames]: number;
|
|
47
|
+
[Counter.Fps]: number;
|
|
48
|
+
[Counter.ChangeLevel]: number;
|
|
49
|
+
[Counter.Seek]: number;
|
|
50
|
+
[Counter.Fullscreen]: number;
|
|
51
|
+
[Counter.DvrUsage]: number;
|
|
18
52
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Time measurements - accumulated duration of time-based activities
|
|
55
|
+
*/
|
|
56
|
+
chrono: {
|
|
57
|
+
/**
|
|
58
|
+
* Time spent in the startup phase
|
|
59
|
+
*/
|
|
60
|
+
[Chronograph.Startup]: number;
|
|
61
|
+
/**
|
|
62
|
+
* Total time spent in the watch phase
|
|
63
|
+
*/
|
|
64
|
+
[Chronograph.Watch]: number;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
[Chronograph.Pause]: number;
|
|
69
|
+
[Chronograph.Buffering]: number;
|
|
70
|
+
[Chronograph.Session]: number;
|
|
71
|
+
// [Chronograph.Latency]: number;
|
|
26
72
|
};
|
|
27
73
|
extra: {
|
|
28
74
|
playbackName: string;
|
|
@@ -51,15 +97,16 @@ export type BitrateTrackRecord = {
|
|
|
51
97
|
bitrate: number;
|
|
52
98
|
}
|
|
53
99
|
|
|
54
|
-
/**
|
|
55
|
-
* @beta
|
|
56
|
-
*/
|
|
57
|
-
export type MetricsUpdateFn = (metrics: Metrics) => void;
|
|
58
|
-
|
|
59
100
|
/**
|
|
60
101
|
* @beta
|
|
61
102
|
*/
|
|
62
103
|
export enum ClapprStatsEvents {
|
|
63
|
-
|
|
64
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Emitted periodically with current measurements.
|
|
106
|
+
*/
|
|
107
|
+
REPORT = 'clappr:stats:report',
|
|
108
|
+
/**
|
|
109
|
+
* Emitted when the playback reaches a certain percentage of the total duration.
|
|
110
|
+
*/
|
|
111
|
+
// PERCENTAGE = 'clappr:stats:percentage',
|
|
65
112
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMockCore } from '../../../testUtils'
|
|
2
2
|
import { ErrorScreen } from '../ErrorScreen'
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
4
4
|
|
|
@@ -9,9 +9,8 @@ describe('ErrorScreen', () => {
|
|
|
9
9
|
let errorScreen: ErrorScreen
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
core = createMockCore()
|
|
12
|
-
container =
|
|
13
|
-
playback =
|
|
14
|
-
container.playback = playback
|
|
12
|
+
container = core.activeContainer
|
|
13
|
+
playback = container.playback
|
|
15
14
|
core.activeContainer = container
|
|
16
15
|
})
|
|
17
16
|
describe('on error', () => {
|
package/src/testUtils.ts
CHANGED
|
@@ -84,7 +84,7 @@ export class _MockPlayback extends Events {
|
|
|
84
84
|
|
|
85
85
|
export function createMockCore(
|
|
86
86
|
options: Record<string, unknown> = {},
|
|
87
|
-
container: any = createMockContainer(),
|
|
87
|
+
container: any = createMockContainer(options),
|
|
88
88
|
) {
|
|
89
89
|
const el = document.createElement('div')
|
|
90
90
|
const emitter = new Events()
|
|
@@ -157,12 +157,13 @@ export function createMockPlayback(name = 'mock') {
|
|
|
157
157
|
})
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
export function createMockContainer(playback: any = createMockPlayback()) {
|
|
160
|
+
export function createMockContainer(options: Record<string, unknown> = {}, playback: any = createMockPlayback()) {
|
|
161
161
|
const el = playback.el
|
|
162
162
|
const emitter = new Events()
|
|
163
163
|
return Object.assign(emitter, {
|
|
164
164
|
el,
|
|
165
165
|
playback,
|
|
166
|
+
options,
|
|
166
167
|
$el: $(el),
|
|
167
168
|
getDuration: vi.fn().mockReturnValue(0),
|
|
168
169
|
getPlugin: vi.fn(),
|