@gcorevideo/player 2.19.15 → 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.
- package/assets/level-selector/list.ejs +1 -1
- package/dist/core.js +2 -2
- package/dist/index.css +1634 -1634
- package/dist/index.js +585 -416
- package/dist/player.d.ts +268 -72
- package/dist/plugins/index.css +1567 -1567
- package/dist/plugins/index.js +526 -357
- package/docs/api/player.clapprnerdstats.md +12 -259
- package/docs/api/player.dvrcontrols.md +5 -1
- package/docs/api/player.errorscreen.attributes.md +3 -0
- package/docs/api/player.errorscreen.bindevents.md +3 -0
- package/docs/api/player.errorscreen.container.md +3 -0
- package/docs/api/player.errorscreen.hide.md +3 -0
- package/docs/api/player.errorscreen.md +27 -0
- package/docs/api/player.errorscreen.name.md +3 -0
- package/docs/api/player.errorscreen.render.md +3 -0
- package/docs/api/player.errorscreen.show.md +3 -0
- package/docs/api/player.errorscreen.supportedversion.md +3 -0
- package/docs/api/player.errorscreen.template.md +3 -0
- package/docs/api/player.errorscreen.unbindevents.md +3 -0
- package/docs/api/{player.playbackrate.template.md → player.initeventdata.event.md} +3 -3
- package/docs/api/{player.playbackrate.updateplaybackrate.md → player.initeventdata.md} +15 -11
- package/docs/api/player.md +88 -5
- package/docs/api/player.pictureinpicture.md +9 -197
- package/docs/api/player.playbackrate.md +10 -314
- package/docs/api/{player.playbackrate.onplay.md → player.stalleventdata.count.md} +5 -7
- package/docs/api/{player.playbackrate.name.md → player.stalleventdata.event.md} +3 -3
- package/docs/api/player.stalleventdata.md +112 -0
- package/docs/api/player.stalleventdata.time.md +13 -0
- package/docs/api/player.stalleventdata.total_ms.md +13 -0
- package/docs/api/{player.pluginsettings.md → player.starteventdata.event.md} +3 -5
- package/docs/api/{player.playbackrate.onrateselect.md → player.starteventdata.md} +15 -11
- package/docs/api/{player.statistics._constructor_.md → player.telemetry._constructor_.md} +6 -3
- package/docs/api/player.telemetry.md +146 -0
- package/docs/api/{player.volumefade.name.md → player.telemetry.name.md} +4 -2
- package/docs/api/{player.clapprnerdstats.supportedversion.md → player.telemetry.supportedversion.md} +4 -2
- package/docs/api/player.telemetryevent.md +89 -0
- package/docs/api/player.telemetryeventdata.md +15 -0
- package/docs/api/player.telemetrypluginsettings.md +57 -0
- package/docs/api/player.telemetrypluginsettings.send.md +13 -0
- package/docs/api/player.telemetryrecord.md +17 -0
- package/docs/api/player.volumefade.md +0 -93
- package/docs/api/{player.pictureinpicture.name.md → player.watcheventdata.event.md} +3 -3
- package/docs/api/{player.playbackrate.setselectedrate.md → player.watcheventdata.md} +15 -11
- package/lib/index.plugins.d.ts +2 -2
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +2 -2
- package/lib/playback/hls-playback/HlsPlayback.js +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +38 -5
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +63 -17
- package/lib/plugins/dvr-controls/DvrControls.d.ts +5 -2
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DvrControls.js +5 -2
- package/lib/plugins/error-screen/ErrorScreen.d.ts +5 -0
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
- package/lib/plugins/error-screen/ErrorScreen.js +5 -0
- package/lib/plugins/index.d.ts +2 -3
- package/lib/plugins/index.d.ts.map +1 -1
- package/lib/plugins/index.js +2 -3
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +32 -4
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
- package/lib/plugins/picture-in-picture/PictureInPicture.js +30 -2
- package/lib/plugins/playback-rate/PlaybackRate.d.ts +47 -14
- package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
- package/lib/plugins/playback-rate/PlaybackRate.js +38 -9
- package/lib/plugins/statistics/Statistics.d.ts +38 -3
- package/lib/plugins/statistics/Statistics.d.ts.map +1 -1
- package/lib/plugins/statistics/Statistics.js +51 -9
- package/lib/plugins/telemetry/Telemetry.d.ts +135 -0
- package/lib/plugins/telemetry/Telemetry.d.ts.map +1 -0
- package/lib/plugins/telemetry/Telemetry.js +180 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts +7 -1
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -1
- package/lib/plugins/volume-fade/VolumeFade.js +8 -1
- package/package.json +1 -1
- package/src/index.plugins.ts +2 -2
- package/src/playback/hls-playback/HlsPlayback.ts +1 -1
- package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +240 -173
- package/src/plugins/dvr-controls/DvrControls.ts +5 -2
- package/src/plugins/error-screen/ErrorScreen.ts +5 -0
- package/src/plugins/index.ts +2 -3
- package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +47 -26
- package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +18 -18
- package/src/plugins/picture-in-picture/PictureInPicture.ts +35 -7
- package/src/plugins/playback-rate/PlaybackRate.ts +53 -24
- package/src/plugins/telemetry/Telemetry.ts +299 -0
- package/src/plugins/volume-fade/VolumeFade.ts +9 -2
- package/temp/player.api.json +2322 -3281
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.clapprnerdstats.attributes.md +0 -17
- package/docs/api/player.clapprnerdstats.bindevents.md +0 -18
- package/docs/api/player.clapprnerdstats.events.md +0 -18
- package/docs/api/player.clapprnerdstats.name.md +0 -14
- package/docs/api/player.clapprnerdstats.playerheight.md +0 -14
- package/docs/api/player.clapprnerdstats.playerwidth.md +0 -14
- package/docs/api/player.clapprnerdstats.render.md +0 -18
- package/docs/api/player.clapprnerdstats.statsboxelem.md +0 -14
- package/docs/api/player.clapprnerdstats.statsboxwidththreshold.md +0 -14
- package/docs/api/player.clapprnerdstats.template.md +0 -14
- package/docs/api/player.pictureinpicture.bindevents.md +0 -15
- package/docs/api/player.pictureinpicture.events.md +0 -13
- package/docs/api/player.pictureinpicture.exitpictureinpicture.md +0 -15
- package/docs/api/player.pictureinpicture.render.md +0 -15
- package/docs/api/player.pictureinpicture.requestpictureinpicture.md +0 -15
- package/docs/api/player.pictureinpicture.supportedversion.md +0 -13
- package/docs/api/player.pictureinpicture.togglepictureinpicture.md +0 -15
- package/docs/api/player.pictureinpicture.version.md +0 -11
- package/docs/api/player.pictureinpicture.videoelement.md +0 -11
- package/docs/api/player.playbackrate.attributes.md +0 -14
- package/docs/api/player.playbackrate.bindevents.md +0 -15
- package/docs/api/player.playbackrate.events.md +0 -15
- package/docs/api/player.playbackrate.gettitle.md +0 -15
- package/docs/api/player.playbackrate.goback.md +0 -15
- package/docs/api/player.playbackrate.highlightcurrentrate.md +0 -15
- package/docs/api/player.playbackrate.onfinishad.md +0 -15
- package/docs/api/player.playbackrate.onshowmenu.md +0 -15
- package/docs/api/player.playbackrate.onstartad.md +0 -15
- package/docs/api/player.playbackrate.onstop.md +0 -15
- package/docs/api/player.playbackrate.reload.md +0 -15
- package/docs/api/player.playbackrate.render.md +0 -15
- package/docs/api/player.playbackrate.supportedversion.md +0 -13
- package/docs/api/player.playbackrate.unbindevents.md +0 -15
- package/docs/api/player.statistics.bindevents.md +0 -15
- package/docs/api/player.statistics.md +0 -141
- package/docs/api/player.statistics.name.md +0 -11
- package/docs/api/player.statistics.supportedversion.md +0 -13
- package/docs/api/player.volumefade.bindevents.md +0 -18
- package/docs/api/player.volumefade.unbindevents.md +0 -18
- package/src/plugins/statistics/Statistics.ts +0 -207
- /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 {
|
|
7
|
-
|
|
8
|
-
|
|
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, GearEvents } 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(
|
|
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 = (
|
|
80
|
-
|
|
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 '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
|
-
|
|
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
|
-
|
|
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 ?? [
|
|
176
|
-
|
|
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(
|
|
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(
|
|
201
|
-
'
|
|
202
|
-
|
|
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(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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:
|
|
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 = [
|
|
255
|
-
|
|
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 =
|
|
272
|
-
|
|
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(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
313
|
-
this.
|
|
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('bottom_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
|
-
*
|
|
15
|
-
*
|
|
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);
|
package/src/plugins/index.ts
CHANGED
|
@@ -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";
|