@gcorevideo/player 2.22.18 → 2.22.20
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/audio-selector/track-selector.ejs +3 -3
- package/assets/bottom-gear/bottomgear.ejs +3 -3
- package/assets/dvr-controls/dvr_controls.scss +0 -12
- package/dist/core.js +1 -1
- package/dist/index.css +803 -810
- package/dist/index.js +195 -176
- package/dist/player.d.ts +121 -108
- package/dist/plugins/index.css +904 -911
- package/dist/plugins/index.js +132 -112
- package/docs/api/player.bitratetrackrecord.md +20 -0
- package/docs/api/player.clapprstats.exportmetrics.md +2 -2
- package/docs/api/player.clapprstats.md +0 -4
- package/docs/api/player.clapprstatschronograph.md +115 -0
- package/docs/api/player.clapprstatscounter.md +211 -0
- package/docs/api/player.clapprstatsevents.md +51 -0
- package/docs/api/player.clapprstatsmetrics.md +52 -0
- package/docs/api/player.clipspluginsettings.md +1 -1
- package/docs/api/player.md +57 -2
- package/docs/api/player.nerdstats.md +3 -3
- package/docs/api/player.playerconfig.md +1 -1
- package/docs/api/player.playerconfig.playbacktype.md +6 -1
- package/docs/api/player.timeupdate.md +6 -3
- package/lib/plugins/audio-selector/AudioSelector.d.ts +1 -1
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +15 -8
- package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +2 -2
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +4 -4
- package/lib/plugins/clappr-nerd-stats/NerdStats.js +4 -4
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +5 -2
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/ClapprStats.js +31 -33
- package/lib/plugins/clappr-stats/types.d.ts +21 -21
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/types.js +22 -22
- package/lib/plugins/clappr-stats/utils.d.ts +2 -2
- package/lib/plugins/clappr-stats/utils.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
- package/lib/plugins/clips/Clips.d.ts +1 -1
- package/lib/plugins/dvr-controls/DvrControls.d.ts +6 -2
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DvrControls.js +39 -27
- package/lib/plugins/media-control/MediaControl.d.ts +6 -2
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +20 -9
- package/lib/plugins/picture-in-picture/PictureInPicture.js +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.js +1 -1
- package/lib/plugins/vast-ads/VastAds.js +1 -1
- package/lib/plugins/vast-ads/rollmanager.js +1 -1
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +7 -4
- package/lib/types.d.ts +1 -1
- package/package.json +3 -3
- package/src/playback/__tests__/HTML5Video.test.ts +2 -2
- package/src/plugins/audio-selector/AudioSelector.ts +14 -7
- package/src/plugins/audio-selector/__tests__/AudioSelector.test.ts +8 -8
- package/src/plugins/audio-selector/__tests__/__snapshots__/AudioSelector.test.ts.snap +15 -15
- package/src/plugins/bottom-gear/BottomGear.ts +2 -2
- package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +8 -5
- package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +3 -3
- package/src/plugins/clappr-nerd-stats/NerdStats.ts +5 -5
- package/src/plugins/clappr-stats/ClapprStats.ts +41 -40
- package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +12 -12
- package/src/plugins/clappr-stats/types.ts +21 -21
- package/src/plugins/clappr-stats/utils.ts +2 -2
- package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
- package/src/plugins/clips/Clips.ts +1 -1
- package/src/plugins/clips/__tests__/Clips.test.ts +1 -1
- package/src/plugins/clips/__tests__/__snapshots__/Clips.test.ts.snap +1 -1
- package/src/plugins/dvr-controls/DvrControls.ts +51 -37
- package/src/plugins/dvr-controls/__tests__/DvrControls.test.ts +84 -26
- package/src/plugins/dvr-controls/__tests__/__snapshots__/DvrControls.test.ts.snap +0 -12
- package/src/plugins/media-control/MediaControl.ts +21 -9
- package/src/plugins/media-control/__tests__/MediaControl.test.ts +8 -5
- package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +20 -20
- package/src/plugins/picture-in-picture/PictureInPicture.ts +1 -1
- package/src/plugins/subtitles/ClosedCaptions.ts +1 -1
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -1
- package/src/plugins/vast-ads/VastAds.ts +1 -1
- package/src/plugins/vast-ads/rollmanager.ts +1 -1
- package/src/testUtils.ts +11 -5
- package/src/types.ts +1 -1
- package/temp/player.api.json +630 -12
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,8 +8,13 @@ import type {
|
|
|
8
8
|
|
|
9
9
|
import { CLAPPR_VERSION } from '../../build.js'
|
|
10
10
|
import { TimerId } from '../../utils/types.js'
|
|
11
|
-
import type {
|
|
12
|
-
import {
|
|
11
|
+
import type { ClapprStatsMetrics } from './types.js'
|
|
12
|
+
import {
|
|
13
|
+
ClapprStatsEvents,
|
|
14
|
+
ClapprStatsChronograph,
|
|
15
|
+
ClapprStatsCounter,
|
|
16
|
+
} from './types.js'
|
|
17
|
+
export * from './types.js'
|
|
13
18
|
import { newMetrics } from './utils.js'
|
|
14
19
|
|
|
15
20
|
export type ClapprStatsSettings = {
|
|
@@ -26,6 +31,8 @@ export type ClapprStatsSettings = {
|
|
|
26
31
|
* @remarks
|
|
27
32
|
* This plugin does not render anything and is supposed to be extended or used together with other plugins that actually render something.
|
|
28
33
|
*
|
|
34
|
+
* @see {@link NerdStats} - a plugin that visualises the playback metrics
|
|
35
|
+
*
|
|
29
36
|
* Configuration options - {@link ClapprStatsSettings}
|
|
30
37
|
*
|
|
31
38
|
* Events - {@link ClapprStatsEvents}
|
|
@@ -35,14 +42,14 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
35
42
|
|
|
36
43
|
private lastDecodedFramesCount = 0
|
|
37
44
|
|
|
38
|
-
private metrics:
|
|
45
|
+
private metrics: ClapprStatsMetrics = newMetrics()
|
|
39
46
|
|
|
40
|
-
private timers: Record<
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
47
|
+
private timers: Record<ClapprStatsChronograph, number> = {
|
|
48
|
+
[ClapprStatsChronograph.Startup]: 0,
|
|
49
|
+
[ClapprStatsChronograph.Watch]: 0,
|
|
50
|
+
[ClapprStatsChronograph.Pause]: 0,
|
|
51
|
+
[ClapprStatsChronograph.Buffering]: 0,
|
|
52
|
+
[ClapprStatsChronograph.Session]: 0,
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
private runEach: number
|
|
@@ -78,21 +85,15 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
78
85
|
: new Date().getTime()
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
private inc(counter:
|
|
88
|
+
private inc(counter: ClapprStatsCounter) {
|
|
82
89
|
this.metrics.counters[counter] += 1
|
|
83
90
|
}
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
// return this[`_start${timer}`] !== undefined;
|
|
87
|
-
// }
|
|
88
|
-
|
|
89
|
-
private start(timer: Chronograph) {
|
|
90
|
-
// this[`_start${timer}`] = this._now();
|
|
92
|
+
private start(timer: ClapprStatsChronograph) {
|
|
91
93
|
this.timers[timer] = this.now()
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
private stop(timer:
|
|
95
|
-
// this._metrics.timers[timer] += this._now() - this[`_start${timer}`];
|
|
96
|
+
private stop(timer: ClapprStatsChronograph) {
|
|
96
97
|
this.metrics.chrono[timer] += this.now() - this.timers[timer]
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -131,16 +132,16 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
131
132
|
)
|
|
132
133
|
this.listenTo(this.container, CoreEvents.CONTAINER_SEEK, this.onSeek)
|
|
133
134
|
this.listenTo(this.container, CoreEvents.CONTAINER_ERROR, () =>
|
|
134
|
-
this.inc(
|
|
135
|
+
this.inc(ClapprStatsCounter.Error),
|
|
135
136
|
)
|
|
136
137
|
this.listenTo(this.container, CoreEvents.CONTAINER_FULLSCREEN, () =>
|
|
137
|
-
this.inc(
|
|
138
|
+
this.inc(ClapprStatsCounter.Fullscreen),
|
|
138
139
|
)
|
|
139
140
|
this.listenTo(
|
|
140
141
|
this.container,
|
|
141
142
|
CoreEvents.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
142
143
|
(dvrInUse: boolean) => {
|
|
143
|
-
dvrInUse && this.inc(
|
|
144
|
+
dvrInUse && this.inc(ClapprStatsCounter.DvrUsage)
|
|
144
145
|
},
|
|
145
146
|
)
|
|
146
147
|
this.listenTo(
|
|
@@ -186,7 +187,7 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
186
187
|
|
|
187
188
|
this.metrics.extra.bitratesHistory.push({ start: this.now(), bitrate })
|
|
188
189
|
|
|
189
|
-
this.inc(
|
|
190
|
+
this.inc(ClapprStatsCounter.ChangeLevel)
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
private stopReporting() {
|
|
@@ -200,8 +201,8 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
200
201
|
|
|
201
202
|
private startTimers() {
|
|
202
203
|
this.timerId = setInterval(this.buildReport.bind(this), this.runEach)
|
|
203
|
-
this.start(
|
|
204
|
-
this.start(
|
|
204
|
+
this.start(ClapprStatsChronograph.Session)
|
|
205
|
+
this.start(ClapprStatsChronograph.Startup)
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
private onFirstPlaying() {
|
|
@@ -211,8 +212,8 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
211
212
|
this.onContainerUpdateWhilePlaying,
|
|
212
213
|
)
|
|
213
214
|
|
|
214
|
-
this.start(
|
|
215
|
-
this.stop(
|
|
215
|
+
this.start(ClapprStatsChronograph.Watch)
|
|
216
|
+
this.stop(ClapprStatsChronograph.Startup)
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
private playAfterPause() {
|
|
@@ -221,18 +222,18 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
221
222
|
CoreEvents.CONTAINER_TIMEUPDATE,
|
|
222
223
|
this.onContainerUpdateWhilePlaying,
|
|
223
224
|
)
|
|
224
|
-
this.stop(
|
|
225
|
-
this.start(
|
|
225
|
+
this.stop(ClapprStatsChronograph.Pause)
|
|
226
|
+
this.start(ClapprStatsChronograph.Watch)
|
|
226
227
|
}
|
|
227
228
|
|
|
228
229
|
private onPlay() {
|
|
229
|
-
this.inc(
|
|
230
|
+
this.inc(ClapprStatsCounter.Play)
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
private onPause() {
|
|
233
|
-
this.stop(
|
|
234
|
-
this.start(
|
|
235
|
-
this.inc(
|
|
234
|
+
this.stop(ClapprStatsChronograph.Watch)
|
|
235
|
+
this.start(ClapprStatsChronograph.Pause)
|
|
236
|
+
this.inc(ClapprStatsCounter.Pause)
|
|
236
237
|
this.listenToOnce(
|
|
237
238
|
this.container,
|
|
238
239
|
CoreEvents.CONTAINER_PLAY,
|
|
@@ -246,7 +247,7 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
private onSeek(e: number) {
|
|
249
|
-
this.inc(
|
|
250
|
+
this.inc(ClapprStatsCounter.Seek)
|
|
250
251
|
this.metrics.extra.watchHistory.push([e * 1000, e * 1000])
|
|
251
252
|
}
|
|
252
253
|
|
|
@@ -282,14 +283,14 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
282
283
|
|
|
283
284
|
private onContainerUpdateWhilePlaying() {
|
|
284
285
|
if (this.container.playback.isPlaying()) {
|
|
285
|
-
this.stop(
|
|
286
|
-
this.start(
|
|
286
|
+
this.stop(ClapprStatsChronograph.Watch)
|
|
287
|
+
this.start(ClapprStatsChronograph.Watch)
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
private onBuffering() {
|
|
291
|
-
this.inc(
|
|
292
|
-
this.start(
|
|
292
|
+
this.inc(ClapprStatsCounter.Buffering)
|
|
293
|
+
this.start(ClapprStatsChronograph.Buffering)
|
|
293
294
|
this.listenToOnce(
|
|
294
295
|
this.container,
|
|
295
296
|
CoreEvents.CONTAINER_STATE_BUFFERFULL,
|
|
@@ -298,7 +299,7 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
private onBufferfull() {
|
|
301
|
-
this.stop(
|
|
302
|
+
this.stop(ClapprStatsChronograph.Buffering)
|
|
302
303
|
this.listenToOnce(
|
|
303
304
|
this.container,
|
|
304
305
|
CoreEvents.CONTAINER_STATE_BUFFERING,
|
|
@@ -317,8 +318,8 @@ export class ClapprStats extends ContainerPlugin {
|
|
|
317
318
|
}
|
|
318
319
|
|
|
319
320
|
private buildReport() {
|
|
320
|
-
this.stop(
|
|
321
|
-
this.start(
|
|
321
|
+
this.stop(ClapprStatsChronograph.Session)
|
|
322
|
+
this.start(ClapprStatsChronograph.Session)
|
|
322
323
|
|
|
323
324
|
this.metrics.extra.playbackName = this.playbackName
|
|
324
325
|
this.metrics.extra.playbackType = this.playbackType
|
|
@@ -4,7 +4,7 @@ import FakeTimers from '@sinonjs/fake-timers'
|
|
|
4
4
|
|
|
5
5
|
import { ClapprStats } from '../ClapprStats'
|
|
6
6
|
import { createMockCore } from '../../../testUtils'
|
|
7
|
-
import {
|
|
7
|
+
import { ClapprStatsChronograph, ClapprStatsCounter, ClapprStatsEvents } from '../types'
|
|
8
8
|
|
|
9
9
|
describe('ClapprStats', () => {
|
|
10
10
|
let core: any
|
|
@@ -29,7 +29,7 @@ describe('ClapprStats', () => {
|
|
|
29
29
|
})
|
|
30
30
|
it('should measure', () => {
|
|
31
31
|
const metrics = stats.exportMetrics()
|
|
32
|
-
expect(metrics.chrono[
|
|
32
|
+
expect(metrics.chrono[ClapprStatsChronograph.Startup]).toBe(155)
|
|
33
33
|
// expect(metrics.times[Chronograph.Session]).toBe(155)
|
|
34
34
|
})
|
|
35
35
|
})
|
|
@@ -50,8 +50,8 @@ describe('ClapprStats', () => {
|
|
|
50
50
|
})
|
|
51
51
|
it('should measure cumulative play and pause durations', () => {
|
|
52
52
|
const metrics = stats.exportMetrics()
|
|
53
|
-
expect(metrics.chrono[
|
|
54
|
-
expect(metrics.chrono[
|
|
53
|
+
expect(metrics.chrono[ClapprStatsChronograph.Watch]).toBe(3850)
|
|
54
|
+
expect(metrics.chrono[ClapprStatsChronograph.Pause]).toBe(2900)
|
|
55
55
|
})
|
|
56
56
|
})
|
|
57
57
|
describe('buffering', () => {
|
|
@@ -71,7 +71,7 @@ describe('ClapprStats', () => {
|
|
|
71
71
|
})
|
|
72
72
|
it('should measure cumulative buffering durations', () => {
|
|
73
73
|
const metrics = stats.exportMetrics()
|
|
74
|
-
expect(metrics.chrono[
|
|
74
|
+
expect(metrics.chrono[ClapprStatsChronograph.Buffering]).toBe(200)
|
|
75
75
|
})
|
|
76
76
|
})
|
|
77
77
|
describe('session', () => {
|
|
@@ -88,7 +88,7 @@ describe('ClapprStats', () => {
|
|
|
88
88
|
it('should measure', () => {
|
|
89
89
|
expect(onReport).toHaveBeenCalledWith(expect.objectContaining({
|
|
90
90
|
chrono: expect.objectContaining({
|
|
91
|
-
[
|
|
91
|
+
[ClapprStatsChronograph.Session]: 60200,
|
|
92
92
|
}),
|
|
93
93
|
}))
|
|
94
94
|
})
|
|
@@ -116,16 +116,16 @@ describe('ClapprStats', () => {
|
|
|
116
116
|
it('should measure fps', () => {
|
|
117
117
|
expect(onReport).toHaveBeenNthCalledWith(1, expect.objectContaining({
|
|
118
118
|
counters: expect.objectContaining({
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
[
|
|
119
|
+
[ClapprStatsCounter.DecodedFrames]: 126,
|
|
120
|
+
[ClapprStatsCounter.DroppedFrames]: 3,
|
|
121
|
+
[ClapprStatsCounter.Fps]: expect.closeTo(25, 0),
|
|
122
122
|
}),
|
|
123
123
|
}))
|
|
124
124
|
expect(onReport).toHaveBeenNthCalledWith(2, expect.objectContaining({
|
|
125
125
|
counters: expect.objectContaining({
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
[
|
|
126
|
+
[ClapprStatsCounter.DecodedFrames]: 275,
|
|
127
|
+
[ClapprStatsCounter.DroppedFrames]: 4,
|
|
128
|
+
[ClapprStatsCounter.Fps]: expect.closeTo(30, 0),
|
|
129
129
|
}),
|
|
130
130
|
}))
|
|
131
131
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @beta
|
|
3
3
|
*/
|
|
4
|
-
export enum
|
|
4
|
+
export enum ClapprStatsChronograph {
|
|
5
5
|
Startup = 'startup',
|
|
6
6
|
Watch = 'watch',
|
|
7
7
|
Pause = 'pause',
|
|
@@ -13,7 +13,7 @@ export enum Chronograph {
|
|
|
13
13
|
/**
|
|
14
14
|
* @beta
|
|
15
15
|
*/
|
|
16
|
-
export enum
|
|
16
|
+
export enum ClapprStatsCounter {
|
|
17
17
|
Play = 'play',
|
|
18
18
|
Pause = 'pause',
|
|
19
19
|
Error = 'error',
|
|
@@ -30,7 +30,7 @@ export enum Counter {
|
|
|
30
30
|
/**
|
|
31
31
|
* @beta
|
|
32
32
|
*/
|
|
33
|
-
export type
|
|
33
|
+
export type ClapprStatsMetrics = {
|
|
34
34
|
/**
|
|
35
35
|
* Events count counters
|
|
36
36
|
*/
|
|
@@ -38,17 +38,17 @@ export type Metrics = {
|
|
|
38
38
|
/**
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
41
|
+
[ClapprStatsCounter.Play]: number
|
|
42
|
+
[ClapprStatsCounter.Pause]: number
|
|
43
|
+
[ClapprStatsCounter.Error]: number
|
|
44
|
+
[ClapprStatsCounter.Buffering]: number
|
|
45
|
+
[ClapprStatsCounter.DecodedFrames]: number
|
|
46
|
+
[ClapprStatsCounter.DroppedFrames]: number
|
|
47
|
+
[ClapprStatsCounter.Fps]: number
|
|
48
|
+
[ClapprStatsCounter.ChangeLevel]: number
|
|
49
|
+
[ClapprStatsCounter.Seek]: number
|
|
50
|
+
[ClapprStatsCounter.Fullscreen]: number
|
|
51
|
+
[ClapprStatsCounter.DvrUsage]: number
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Time measurements - accumulated duration of time-based activities
|
|
@@ -57,23 +57,23 @@ export type Metrics = {
|
|
|
57
57
|
/**
|
|
58
58
|
* Time spent in the startup phase
|
|
59
59
|
*/
|
|
60
|
-
[
|
|
60
|
+
[ClapprStatsChronograph.Startup]: number
|
|
61
61
|
/**
|
|
62
62
|
* Total time spent in the watch phase
|
|
63
63
|
*/
|
|
64
|
-
[
|
|
64
|
+
[ClapprStatsChronograph.Watch]: number
|
|
65
65
|
/**
|
|
66
66
|
*
|
|
67
67
|
*/
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
68
|
+
[ClapprStatsChronograph.Pause]: number
|
|
69
|
+
[ClapprStatsChronograph.Buffering]: number
|
|
70
|
+
[ClapprStatsChronograph.Session]: number
|
|
71
71
|
// [Chronograph.Latency]: number;
|
|
72
72
|
}
|
|
73
73
|
extra: {
|
|
74
74
|
playbackName: string
|
|
75
75
|
playbackType: string
|
|
76
|
-
bitratesHistory:
|
|
76
|
+
bitratesHistory: ClapprStatsBitrateTrack[]
|
|
77
77
|
bitrateWeightedMean: number
|
|
78
78
|
bitrateMostUsed: number
|
|
79
79
|
buffersize: number
|
|
@@ -89,7 +89,7 @@ export type Metrics = {
|
|
|
89
89
|
/**
|
|
90
90
|
* @beta
|
|
91
91
|
*/
|
|
92
|
-
export type
|
|
92
|
+
export type ClapprStatsBitrateTrack = {
|
|
93
93
|
start: number
|
|
94
94
|
end?: number
|
|
95
95
|
time?: number
|
|
@@ -12,7 +12,7 @@ import clipsHTML from '../../../assets/clips/clips.ejs'
|
|
|
12
12
|
const T = 'plugins.clips'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Configuration options for the {@link
|
|
15
|
+
* Configuration options for the {@link Clips} plugin.
|
|
16
16
|
* @beta
|
|
17
17
|
*/
|
|
18
18
|
export interface ClipsPluginSettings {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`Clips > should render indicator 1`] = `
|
|
4
4
|
"<div class="media-clip-text" id="clips-text">Introduction</div><svg width="0" height="0">
|
|
5
5
|
<defs>
|
|
6
6
|
<clipPath id="myClip">
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Events, Playback, UICorePlugin, template } from '@clappr/core'
|
|
2
2
|
import assert from 'assert'
|
|
3
3
|
|
|
4
4
|
import { CLAPPR_VERSION } from '../../build.js'
|
|
5
5
|
|
|
6
6
|
import dvrHTML from '../../../assets/dvr-controls/index.ejs'
|
|
7
7
|
import '../../../assets/dvr-controls/dvr_controls.scss'
|
|
8
|
-
import { trace } from '@gcorevideo/utils'
|
|
8
|
+
// import { trace } from '@gcorevideo/utils'
|
|
9
9
|
import { MediaControl } from '../media-control/MediaControl.js'
|
|
10
10
|
|
|
11
|
-
const T = 'plugins.dvr_controls'
|
|
11
|
+
// const T = 'plugins.dvr_controls'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* `PLUGIN` that adds the DVR controls to the media control UI
|
|
@@ -63,11 +63,11 @@ export class DvrControls extends UICorePlugin {
|
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
65
|
override bindEvents() {
|
|
66
|
-
this.
|
|
66
|
+
this.listenToOnce(this.core, Events.CORE_READY, this.onCoreReady)
|
|
67
67
|
this.listenTo(
|
|
68
68
|
this.core,
|
|
69
69
|
Events.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
70
|
-
this.
|
|
70
|
+
this.onActiveContainerChanged,
|
|
71
71
|
)
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -75,21 +75,19 @@ export class DvrControls extends UICorePlugin {
|
|
|
75
75
|
const mediaControl = this.core.getPlugin('media_control')
|
|
76
76
|
assert(mediaControl, 'media_control plugin is required')
|
|
77
77
|
|
|
78
|
-
this.listenTo(
|
|
79
|
-
mediaControl,
|
|
80
|
-
Events.MEDIACONTROL_RENDERED,
|
|
81
|
-
this.render,
|
|
82
|
-
)
|
|
83
|
-
// MediaControl has been rendered
|
|
84
|
-
this.render()
|
|
78
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_RENDERED, this.mount)
|
|
85
79
|
}
|
|
86
80
|
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
this.listenToOnce(
|
|
81
|
+
private onActiveContainerChanged() {
|
|
82
|
+
this.listenTo(
|
|
90
83
|
this.core.activeContainer,
|
|
91
|
-
Events.
|
|
92
|
-
this.
|
|
84
|
+
Events.CONTAINER_LOADEDMETADATA,
|
|
85
|
+
this.onMetadataLoaded,
|
|
86
|
+
)
|
|
87
|
+
this.listenTo(
|
|
88
|
+
this.core.activeContainer,
|
|
89
|
+
Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
90
|
+
this.onDvrStateChanged,
|
|
93
91
|
)
|
|
94
92
|
}
|
|
95
93
|
|
|
@@ -101,36 +99,52 @@ export class DvrControls extends UICorePlugin {
|
|
|
101
99
|
container.seek(container.getDuration())
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
private shouldRender() {
|
|
105
|
-
return this.core.getPlaybackType() === Playback.LIVE
|
|
106
|
-
}
|
|
107
|
-
|
|
108
102
|
/**
|
|
109
103
|
* @internal
|
|
110
104
|
*/
|
|
111
105
|
override render() {
|
|
112
|
-
trace(`${T} render`, {
|
|
113
|
-
dvrEnabled: this.core.activePlayback?.dvrEnabled,
|
|
114
|
-
playbackType: this.core.getPlaybackType(),
|
|
115
|
-
})
|
|
116
|
-
const mediaControl = this.core.getPlugin('media_control') as MediaControl
|
|
117
|
-
if (!mediaControl) {
|
|
118
|
-
return this
|
|
119
|
-
}
|
|
120
|
-
if (!this.shouldRender()) {
|
|
121
|
-
return this
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
mediaControl.toggleElement('duration', false)
|
|
125
|
-
mediaControl.toggleElement('position', false)
|
|
126
|
-
|
|
127
106
|
this.$el.html(
|
|
128
107
|
DvrControls.template({
|
|
129
108
|
i18n: this.core.i18n,
|
|
130
109
|
}),
|
|
131
110
|
)
|
|
132
|
-
mediaControl.putElement('dvr', this.$el)
|
|
133
111
|
|
|
134
112
|
return this
|
|
135
113
|
}
|
|
114
|
+
|
|
115
|
+
private onMediacontrolRendered() {
|
|
116
|
+
this.render()
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private onMetadataLoaded() {
|
|
120
|
+
this.mount()
|
|
121
|
+
this.toggleState(this.core.activeContainer.isDvrInUse())
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private mount() {
|
|
125
|
+
// TODO move mount point management logic to MediaControl
|
|
126
|
+
if (this.core.getPlaybackType() !== Playback.LIVE) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
const mediaControl = this.core.getPlugin('media_control') as MediaControl
|
|
130
|
+
assert(mediaControl, 'media_control plugin is required')
|
|
131
|
+
// TODO -> to MediaControl
|
|
132
|
+
mediaControl.toggleElement('duration', false)
|
|
133
|
+
mediaControl.toggleElement('position', false)
|
|
134
|
+
mediaControl.mount('dvr', this.$el)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private onDvrStateChanged(dvrInUse: boolean) {
|
|
138
|
+
this.toggleState(dvrInUse)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private toggleState(dvrInUse: boolean) {
|
|
142
|
+
if (dvrInUse) {
|
|
143
|
+
this.$el.find('#media-control-back-to-live').show()
|
|
144
|
+
this.$el.find('#media-control-live').hide()
|
|
145
|
+
} else {
|
|
146
|
+
this.$el.find('#media-control-back-to-live').hide()
|
|
147
|
+
this.$el.find('#media-control-live').show()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
136
150
|
}
|