@gumlet/insights-js-core 1.0.3 → 1.1.0
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/.github/workflows/main.yml +87 -0
- package/.gitlab-ci.yml +54 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/bitbucket-pipelines.yml +35 -0
- package/docs/payload-documentation.md +72 -0
- package/html/bitmovin.html +82 -0
- package/html/dashjs.html +55 -0
- package/html/hlsjs.html +72 -0
- package/html/html5.html +59 -0
- package/html/shaka.html +102 -0
- package/html/videojs.html +67 -0
- package/index.html +73 -0
- package/jest.config.js +187 -0
- package/js/adapters/Bitmovin7Adapter.js +352 -0
- package/js/adapters/BitmovinAdapter.js +198 -0
- package/js/adapters/DashjsAdapter.js +140 -0
- package/js/adapters/HTML5Adapter.js +774 -0
- package/js/adapters/HlsjsAdapter.js +152 -0
- package/js/adapters/ShakaAdapter.js +81 -0
- package/js/adapters/VideoJsAdapter.js +455 -0
- package/js/analyticsStateMachines/Bitmovin7AnalyticsStateMachine.js +471 -0
- package/js/analyticsStateMachines/BitmovinAnalyticsStateMachine.js +299 -0
- package/js/analyticsStateMachines/HTML5AnalyticsStateMachine.js +443 -0
- package/js/analyticsStateMachines/VideoJsAnalyticsStateMachine.js +503 -0
- package/js/cast/CastClient.js +50 -0
- package/js/cast/CastReceiver.js +37 -0
- package/js/core/AdapterFactory.js +41 -0
- package/js/core/Analytics.js +1357 -0
- package/js/core/AnalyticsStateMachineFactory.js +36 -0
- package/js/core/GumletInsightsExport.js +75 -0
- package/js/enums/CDNProviders.js +11 -0
- package/js/enums/Events.js +32 -0
- package/js/enums/GumletEnum.js +19 -0
- package/js/enums/MIMETypes.js +30 -0
- package/js/enums/Players.js +11 -0
- package/js/enums/StreamTypes.js +15 -0
- package/js/utils/EventsCall.js +22 -0
- package/js/utils/HttpCall.js +57 -0
- package/js/utils/LicenseCall.js +18 -0
- package/js/utils/Logger.js +40 -0
- package/js/utils/PlayerDetector.js +75 -0
- package/js/utils/PlayerInitCall.js +22 -0
- package/js/utils/SessionCreationCall.js +22 -0
- package/js/utils/Settings.js +3 -0
- package/js/utils/Utils.js +195 -0
- package/package.json +62 -1
- package/precommit.bash +8 -0
- package/tests/stage1.test.js +50 -0
- package/webpack.config.debug.js +34 -0
- package/webpack.config.js +40 -0
- package/webpack.config.release.js +62 -0
- package/gumlet-insights.min.js +0 -2
- package/gumlet-insights.min.js.LICENSE.txt +0 -10
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import Events from '../enums/Events';
|
|
2
|
+
|
|
3
|
+
class Bitmovin7Adapter {
|
|
4
|
+
constructor(player, eventCallback) {
|
|
5
|
+
this.onBeforeUnLoadEvent = false;
|
|
6
|
+
this.player = player;
|
|
7
|
+
this.eventCallback = eventCallback;
|
|
8
|
+
this.register();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
register() {
|
|
12
|
+
|
|
13
|
+
const getProgConfigFromProgressiveConfig = (progressive) => {
|
|
14
|
+
if (!progressive) {
|
|
15
|
+
return {
|
|
16
|
+
progUrl: undefined,
|
|
17
|
+
progBitrate: undefined
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof progressive === 'string') {
|
|
22
|
+
return {
|
|
23
|
+
progUrl: progressive,
|
|
24
|
+
progBitrate: 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(progressive)) {
|
|
29
|
+
const playbackVideoData = this.player.getPlaybackVideoData();
|
|
30
|
+
const progressiveArrayIndex = parseInt(playbackVideoData.id) || 0;
|
|
31
|
+
return {
|
|
32
|
+
progUrl: progressive[progressiveArrayIndex].url,
|
|
33
|
+
progBitrate: progressive[progressiveArrayIndex].bitrate || 0,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof progressive === 'object') {
|
|
38
|
+
return {
|
|
39
|
+
progUrl: progressive.url,
|
|
40
|
+
progBitrate: progressive.bitrate || 0
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/* eslint-disable no-unused-vars */
|
|
45
|
+
this.player.addEventHandler(this.player.EVENT.ON_SOURCE_UNLOADED, (event) => {
|
|
46
|
+
this.eventCallback(Events.SOURCE_UNLOADED, {
|
|
47
|
+
currentTime : this.player.getCurrentTime(),
|
|
48
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.player.addEventHandler(this.player.EVENT.ON_SOURCE_LOADED, (event) => {
|
|
53
|
+
let autoplay = false;
|
|
54
|
+
if (this.player.getConfig().playback && this.player.getConfig().playback.autoplay) {
|
|
55
|
+
autoplay = this.player.getConfig().playback.autoplay;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const config = this.player.getConfig();
|
|
59
|
+
let source = {};
|
|
60
|
+
const progConf = getProgConfigFromProgressiveConfig(config.source.progressive);
|
|
61
|
+
if (config.source) {
|
|
62
|
+
source = {
|
|
63
|
+
mpdUrl : config.source.dash,
|
|
64
|
+
m3u8Url: config.source.hls,
|
|
65
|
+
progUrl: progConf.progUrl,
|
|
66
|
+
progBitrate: progConf.progBitrate
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
this.eventCallback(Events.SOURCE_LOADED, {
|
|
72
|
+
isLive : this.player.isLive(),
|
|
73
|
+
version : this.player.version,
|
|
74
|
+
type : this.player.getPlayerType(),
|
|
75
|
+
duration : this.player.getDuration(),
|
|
76
|
+
streamType : this.player.getStreamType(),
|
|
77
|
+
mpdUrl : source.mpdUrl,
|
|
78
|
+
m3u8Url : source.m3u8Url,
|
|
79
|
+
progUrl : source.progUrl,
|
|
80
|
+
progBitrate : source.progBitrate,
|
|
81
|
+
videoWindowWidth : this.player.getFigure().offsetWidth,
|
|
82
|
+
videoWindowHeight: this.player.getFigure().offsetHeight,
|
|
83
|
+
isMuted : this.player.isMuted(),
|
|
84
|
+
autoplay
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
this.player.addEventHandler(this.player.EVENT.ON_READY, () => {
|
|
89
|
+
let autoplay = false;
|
|
90
|
+
if (this.player.getConfig().playback && this.player.getConfig().playback.autoplay) {
|
|
91
|
+
autoplay = this.player.getConfig().playback.autoplay;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const config = this.player.getConfig();
|
|
95
|
+
let source = {};
|
|
96
|
+
const progConf = getProgConfigFromProgressiveConfig(config.source.progressive);
|
|
97
|
+
if (config.source) {
|
|
98
|
+
source = {
|
|
99
|
+
videoId: config.source.videoId,
|
|
100
|
+
userId : config.source.userId,
|
|
101
|
+
mpdUrl : config.source.dash,
|
|
102
|
+
m3u8Url: config.source.hls,
|
|
103
|
+
progUrl: progConf.progUrl,
|
|
104
|
+
progBitrate: progConf.progBitrate
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// By default preload is true in bitmovin7
|
|
108
|
+
let preload = true;
|
|
109
|
+
if (this.player.getConfig().adaptation.preload != undefined && typeof this.player.getConfig().adaptation.preload == 'boolean') {
|
|
110
|
+
preload = this.player.getConfig().adaptation.preload;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let playerAudioLanguage = this.player.getAudio();
|
|
114
|
+
if (!playerAudioLanguage) {
|
|
115
|
+
playerAudioLanguage = "undetected";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.eventCallback(Events.READY, {
|
|
119
|
+
isLive : this.player.isLive(),
|
|
120
|
+
version : this.player.version,
|
|
121
|
+
type : this.player.getPlayerType(),
|
|
122
|
+
duration : this.player.getDuration(),
|
|
123
|
+
streamType : this.player.getStreamType(),
|
|
124
|
+
videoId : source.videoId,
|
|
125
|
+
userId : source.userId,
|
|
126
|
+
mpdUrl : source.mpdUrl,
|
|
127
|
+
m3u8Url : source.m3u8Url,
|
|
128
|
+
progUrl : source.progUrl,
|
|
129
|
+
progBitrate : source.progBitrate,
|
|
130
|
+
videoWindowWidth : this.player.getFigure().offsetWidth,
|
|
131
|
+
videoWindowHeight: this.player.getFigure().offsetHeight,
|
|
132
|
+
isMuted : this.player.isMuted(),
|
|
133
|
+
preload : preload,
|
|
134
|
+
audioLanguage : playerAudioLanguage,
|
|
135
|
+
isFullScreen : this.player.isFullscreen(),
|
|
136
|
+
autoplay
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
this.player.addEventHandler(this.player.EVENT.ON_CAST_STARTED, (event) => {
|
|
141
|
+
this.eventCallback(Events.START_CAST, event);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
this.player.addEventHandler(this.player.EVENT.ON_CAST_STOPPED, () => {
|
|
145
|
+
this.eventCallback(Events.END_CAST, {
|
|
146
|
+
currentTime : this.player.getCurrentTime(),
|
|
147
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
148
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
149
|
+
isFullScreen : this.player.isFullscreen(),
|
|
150
|
+
isCasting : this.player.isCasting(),
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
this.player.addEventHandler(this.player.EVENT.ON_PLAY, () => {
|
|
155
|
+
this.eventCallback(Events.PLAY, {
|
|
156
|
+
currentTime : this.player.getCurrentTime(),
|
|
157
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
158
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
159
|
+
isFullScreen : this.player.isFullscreen(),
|
|
160
|
+
isCasting : this.player.isCasting(),
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
this.player.addEventHandler(this.player.EVENT.ON_PAUSED, () => {
|
|
165
|
+
this.eventCallback(Events.PAUSE, {
|
|
166
|
+
currentTime : this.player.getCurrentTime(),
|
|
167
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
168
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
169
|
+
isFullScreen : this.player.isFullscreen(),
|
|
170
|
+
isCasting : this.player.isCasting(),
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
this.player.addEventHandler(this.player.EVENT.ON_TIME_CHANGED, () => {
|
|
175
|
+
this.eventCallback(Events.TIMECHANGED, {
|
|
176
|
+
currentTime : this.player.getCurrentTime(),
|
|
177
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
178
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
179
|
+
isFullScreen : this.player.isFullscreen(),
|
|
180
|
+
isCasting : this.player.isCasting(),
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
this.player.addEventHandler(this.player.EVENT.ON_SEEK, () => {
|
|
185
|
+
this.eventCallback(Events.SEEK, {
|
|
186
|
+
currentTime : this.player.getCurrentTime(),
|
|
187
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
188
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
189
|
+
isFullScreen : this.player.isFullscreen(),
|
|
190
|
+
isCasting : this.player.isCasting(),
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
this.player.addEventHandler(this.player.EVENT.ON_SEEKED, () => {
|
|
195
|
+
this.eventCallback(Events.SEEKED, {
|
|
196
|
+
currentTime : this.player.getCurrentTime(),
|
|
197
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
198
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
199
|
+
isFullScreen : this.player.isFullscreen(),
|
|
200
|
+
isCasting : this.player.isCasting(),
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
this.player.addEventHandler(this.player.EVENT.ON_STALL_STARTED, () => {
|
|
205
|
+
this.eventCallback(Events.START_BUFFERING, {
|
|
206
|
+
currentTime : this.player.getCurrentTime(),
|
|
207
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
208
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
209
|
+
isFullScreen : this.player.isFullscreen(),
|
|
210
|
+
isCasting : this.player.isCasting(),
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
this.player.addEventHandler(this.player.EVENT.ON_STALL_ENDED, () => {
|
|
215
|
+
this.eventCallback(Events.END_BUFFERING, {
|
|
216
|
+
currentTime : this.player.getCurrentTime(),
|
|
217
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
218
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
219
|
+
isFullScreen : this.player.isFullscreen(),
|
|
220
|
+
isCasting : this.player.isCasting(),
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
this.player.addEventHandler(this.player.EVENT.ON_AUDIO_PLAYBACK_QUALITY_CHANGED, () => {
|
|
225
|
+
const quality = this.player.getPlaybackAudioData();
|
|
226
|
+
|
|
227
|
+
this.eventCallback(Events.AUDIO_CHANGE, {
|
|
228
|
+
bitrate : quality.bitrate,
|
|
229
|
+
currentTime : this.player.getCurrentTime(),
|
|
230
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
231
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
232
|
+
isFullScreen : this.player.isFullscreen(),
|
|
233
|
+
isCasting : this.player.isCasting(),
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
this.player.addEventHandler(this.player.EVENT.ON_VIDEO_PLAYBACK_QUALITY_CHANGED, () => {
|
|
238
|
+
const quality = this.player.getPlaybackVideoData();
|
|
239
|
+
|
|
240
|
+
this.eventCallback(Events.VIDEO_CHANGE, {
|
|
241
|
+
width : quality.width,
|
|
242
|
+
height : quality.height,
|
|
243
|
+
bitrate : quality.bitrate,
|
|
244
|
+
currentTime : this.player.getCurrentTime(),
|
|
245
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
246
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
247
|
+
isFullScreen : this.player.isFullscreen(),
|
|
248
|
+
isCasting : this.player.isCasting(),
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
this.player.addEventHandler(this.player.EVENT.ON_FULLSCREEN_ENTER, () => {
|
|
253
|
+
this.eventCallback(Events.START_FULLSCREEN, {
|
|
254
|
+
currentTime : this.player.getCurrentTime(),
|
|
255
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
256
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
257
|
+
isFullScreen : this.player.isFullscreen(),
|
|
258
|
+
isCasting : this.player.isCasting(),
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
this.player.addEventHandler(this.player.EVENT.ON_FULLSCREEN_EXIT, () => {
|
|
263
|
+
this.eventCallback(Events.END_FULLSCREEN, {
|
|
264
|
+
currentTime : this.player.getCurrentTime(),
|
|
265
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
266
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
267
|
+
isFullScreen : this.player.isFullscreen(),
|
|
268
|
+
isCasting : this.player.isCasting(),
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
this.player.addEventHandler(this.player.EVENT.ON_AD_STARTED, () => {
|
|
273
|
+
this.eventCallback(Events.START_AD, {
|
|
274
|
+
currentTime : this.player.getCurrentTime(),
|
|
275
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
276
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
277
|
+
isFullScreen : this.player.isFullscreen(),
|
|
278
|
+
isCasting : this.player.isCasting(),
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
this.player.addEventHandler(this.player.EVENT.ON_AD_FINISHED, () => {
|
|
283
|
+
this.eventCallback(Events.END_AD, {
|
|
284
|
+
currentTime : this.player.getCurrentTime(),
|
|
285
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
286
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
287
|
+
isFullScreen : this.player.isFullscreen(),
|
|
288
|
+
isCasting : this.player.isCasting(),
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
this.player.addEventHandler(this.player.EVENT.ON_MUTED, () => {
|
|
293
|
+
this.eventCallback(Events.MUTE, {
|
|
294
|
+
currentTime : this.player.getCurrentTime(),
|
|
295
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
296
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
297
|
+
isFullScreen : this.player.isFullscreen(),
|
|
298
|
+
isCasting : this.player.isCasting(),
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
this.player.addEventHandler(this.player.EVENT.ON_UNMUTED, () => {
|
|
303
|
+
this.eventCallback(Events.UN_MUTE, {
|
|
304
|
+
currentTime : this.player.getCurrentTime(),
|
|
305
|
+
droppedFrames : this.player.getDroppedFrames(),
|
|
306
|
+
currentVideoData : this.player.getPlaybackVideoData(),
|
|
307
|
+
isFullScreen : this.player.isFullscreen(),
|
|
308
|
+
isCasting : this.player.isCasting(),
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
this.player.addEventHandler(this.player.EVENT.ON_ERROR, (event) => {
|
|
313
|
+
this.eventCallback(Events.ERROR, {
|
|
314
|
+
code : event.code,
|
|
315
|
+
message : event.message,
|
|
316
|
+
currentTime : this.player.getCurrentTime()
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
this.player.addEventHandler(this.player.EVENT.ON_PLAYBACK_FINISHED, () => {
|
|
321
|
+
this.eventCallback(Events.PLAYBACK_FINISHED, {
|
|
322
|
+
currentTime : this.player.getCurrentTime(),
|
|
323
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
if (typeof window !== "undefined")
|
|
328
|
+
{
|
|
329
|
+
window.onunload = window.onbeforeunload = () => {
|
|
330
|
+
if (!this.onBeforeUnLoadEvent) {
|
|
331
|
+
this.onBeforeUnLoadEvent = true;
|
|
332
|
+
this.eventCallback(Events.UNLOAD, {
|
|
333
|
+
currentTime : this.player.getCurrentTime(),
|
|
334
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
else{
|
|
340
|
+
if (!this.onBeforeUnLoadEvent) {
|
|
341
|
+
this.onBeforeUnLoadEvent = true;
|
|
342
|
+
this.eventCallback(Events.UNLOAD, {
|
|
343
|
+
currentTime : this.player.getCurrentTime(),
|
|
344
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export default Bitmovin7Adapter;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import Events from '../enums/Events';
|
|
2
|
+
|
|
3
|
+
class BitmovinAdapter {
|
|
4
|
+
constructor(player, eventCallback) {
|
|
5
|
+
this.onBeforeUnLoadEvent = false;
|
|
6
|
+
this.player = player;
|
|
7
|
+
this.eventCallback = eventCallback;
|
|
8
|
+
this.register();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
register() {
|
|
12
|
+
this.player.addEventHandler(this.player.EVENT.ON_SOURCE_LOADED, () => {
|
|
13
|
+
this.eventCallback(Events.SOURCE_LOADED);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
this.player.addEventHandler(this.player.EVENT.ON_READY, () => {
|
|
17
|
+
let autoplay = false;
|
|
18
|
+
if (this.player.getConfig().playback && this.player.getConfig().playback.autoplay) {
|
|
19
|
+
autoplay = this.player.getConfig().playback.autoplay;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.eventCallback(Events.READY, {
|
|
23
|
+
isLive : this.player.isLive(),
|
|
24
|
+
version : this.player.getVersion(),
|
|
25
|
+
type : this.player.getPlayerType(),
|
|
26
|
+
duration : this.player.getDuration(),
|
|
27
|
+
streamType : this.player.getStreamType(),
|
|
28
|
+
videoId : this.player.getConfig().source.videoId,
|
|
29
|
+
userId : this.player.getConfig().source.userId,
|
|
30
|
+
mpdUrl : this.player.getConfig().source.dash,
|
|
31
|
+
m3u8Url : this.player.getConfig().source.hls,
|
|
32
|
+
progUrl : this.player.getConfig().source.progressive,
|
|
33
|
+
videoWindowWidth : this.player.getFigure().offsetWidth,
|
|
34
|
+
videoWindowHeight: this.player.getFigure().offsetHeight,
|
|
35
|
+
isMuted : this.player.isMuted(),
|
|
36
|
+
autoplay
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
this.player.addEventHandler(this.player.EVENT.ON_CAST_START, () => {
|
|
41
|
+
this.eventCallback(Events.START_CAST);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this.player.addEventHandler(this.player.EVENT.ON_CAST_STOP, () => {
|
|
45
|
+
this.eventCallback(Events.END_CAST);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this.player.addEventHandler(this.player.EVENT.ON_PLAY, () => {
|
|
49
|
+
this.eventCallback(Events.PLAY, {
|
|
50
|
+
currentTime : this.player.getCurrentTime(),
|
|
51
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
this.player.addEventHandler(this.player.EVENT.ON_PAUSE, () => {
|
|
56
|
+
this.eventCallback(Events.PAUSE, {
|
|
57
|
+
currentTime : this.player.getCurrentTime(),
|
|
58
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this.player.addEventHandler(this.player.EVENT.ON_TIME_CHANGED, () => {
|
|
63
|
+
this.eventCallback(Events.TIMECHANGED, {
|
|
64
|
+
currentTime : this.player.getCurrentTime(),
|
|
65
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.player.addEventHandler(this.player.EVENT.ON_SEEK, () => {
|
|
70
|
+
this.eventCallback(Events.SEEK, {
|
|
71
|
+
currentTime : this.player.getCurrentTime(),
|
|
72
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
this.player.addEventHandler(this.player.EVENT.ON_SEEKED, () => {
|
|
77
|
+
this.eventCallback(Events.SEEKED, {
|
|
78
|
+
currentTime : this.player.getCurrentTime(),
|
|
79
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
this.player.addEventHandler(this.player.EVENT.ON_START_BUFFERING, () => {
|
|
84
|
+
this.eventCallback(Events.START_BUFFERING);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.player.addEventHandler(this.player.EVENT.ON_STOP_BUFFERING, () => {
|
|
88
|
+
this.eventCallback(Events.END_BUFFERING, {
|
|
89
|
+
currentTime : this.player.getCurrentTime(),
|
|
90
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
this.player.addEventHandler(this.player.EVENT.ON_AUDIO_PLAYBACK_QUALITY_CHANGE, () => {
|
|
95
|
+
const quality = this.player.getPlaybackAudioData();
|
|
96
|
+
|
|
97
|
+
this.eventCallback(Events.AUDIO_CHANGE, {
|
|
98
|
+
bitrate : quality.bitrate,
|
|
99
|
+
currentTime : this.player.getCurrentTime(),
|
|
100
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.player.addEventHandler(this.player.EVENT.ON_VIDEO_PLAYBACK_QUALITY_CHANGE, () => {
|
|
105
|
+
const quality = this.player.getPlaybackVideoData();
|
|
106
|
+
|
|
107
|
+
this.eventCallback(Events.VIDEO_CHANGE, {
|
|
108
|
+
width : quality.width,
|
|
109
|
+
height : quality.height,
|
|
110
|
+
bitrate : quality.bitrate,
|
|
111
|
+
currentTime : this.player.getCurrentTime(),
|
|
112
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
this.player.addEventHandler(this.player.EVENT.ON_FULLSCREEN_ENTER, () => {
|
|
117
|
+
this.eventCallback(Events.START_FULLSCREEN, {
|
|
118
|
+
currentTime : this.player.getCurrentTime(),
|
|
119
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
this.onBeforeUnLoadEvent = false;
|
|
123
|
+
|
|
124
|
+
this.player.addEventHandler(this.player.EVENT.ON_FULLSCREEN_EXIT, () => {
|
|
125
|
+
this.eventCallback(Events.END_FULLSCREEN, {
|
|
126
|
+
currentTime : this.player.getCurrentTime(),
|
|
127
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
this.player.addEventHandler(this.player.EVENT.ON_AD_STARTED, () => {
|
|
132
|
+
this.eventCallback(Events.START_AD, {
|
|
133
|
+
currentTime : this.player.getCurrentTime(),
|
|
134
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
this.player.addEventHandler(this.player.EVENT.ON_AD_FINISHED, () => {
|
|
139
|
+
this.eventCallback(Events.END_AD, {
|
|
140
|
+
currentTime : this.player.getCurrentTime(),
|
|
141
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
this.player.addEventHandler(this.player.EVENT.ON_MUTE, () => {
|
|
146
|
+
this.eventCallback(Events.MUTE, {
|
|
147
|
+
currentTime : this.player.getCurrentTime(),
|
|
148
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
this.player.addEventHandler(this.player.EVENT.ON_UNMUTE, () => {
|
|
153
|
+
this.eventCallback(Events.UN_MUTE, {
|
|
154
|
+
currentTime : this.player.getCurrentTime(),
|
|
155
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
this.player.addEventHandler(this.player.EVENT.ON_ERROR, (event) => {
|
|
160
|
+
this.eventCallback(Events.ERROR, {
|
|
161
|
+
code : event.code,
|
|
162
|
+
message: event.message
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
this.player.addEventHandler(this.player.EVENT.ON_PLAYBACK_FINISHED, () => {
|
|
167
|
+
this.eventCallback(Events.PLAYBACK_FINISHED, {
|
|
168
|
+
currentTime : this.player.getCurrentTime(),
|
|
169
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (typeof window !== "undefined")
|
|
174
|
+
{
|
|
175
|
+
window.onunload = window.onbeforeunload = () => {
|
|
176
|
+
if (!this.onBeforeUnLoadEvent) {
|
|
177
|
+
this.onBeforeUnLoadEvent = true;
|
|
178
|
+
this.eventCallback(Events.UNLOAD, {
|
|
179
|
+
currentTime : this.player.getCurrentTime(),
|
|
180
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
else{
|
|
186
|
+
if (!this.onBeforeUnLoadEvent) {
|
|
187
|
+
this.onBeforeUnLoadEvent = true;
|
|
188
|
+
this.eventCallback(Events.UNLOAD, {
|
|
189
|
+
currentTime : this.player.getCurrentTime(),
|
|
190
|
+
droppedFrames: this.player.getDroppedFrames()
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export default BitmovinAdapter;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* global dashjs */
|
|
2
|
+
|
|
3
|
+
import {HTML5Adapter} from './HTML5Adapter';
|
|
4
|
+
import {MIMETypes} from '../enums/MIMETypes';
|
|
5
|
+
import {Players} from '../enums/Players';
|
|
6
|
+
import Events from '../enums/Events';
|
|
7
|
+
|
|
8
|
+
export class DashjsAdapter extends HTML5Adapter {
|
|
9
|
+
|
|
10
|
+
constructor(mediaPlayer, eventCallback, stateMachine) {
|
|
11
|
+
super(null, eventCallback, stateMachine, Players.DASHJS);
|
|
12
|
+
|
|
13
|
+
let videoEl = null;
|
|
14
|
+
let canPlay = false;
|
|
15
|
+
|
|
16
|
+
this.playerSoftwareName = Players.DASHJS;
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
videoEl = mediaPlayer.getVideoElement();
|
|
20
|
+
} catch(e) { /* eslint-disable-line no-empty */ }
|
|
21
|
+
if (!videoEl) {
|
|
22
|
+
mediaPlayer.on(dashjs.MediaPlayer.events.CAN_PLAY, () => {
|
|
23
|
+
if (canPlay) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// console.log(dashjs.MediaPlayer.events.CAN_PLAY);
|
|
27
|
+
videoEl = mediaPlayer.getVideoElement();
|
|
28
|
+
canPlay = true;
|
|
29
|
+
this._initialize(mediaPlayer, videoEl);
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
duration,
|
|
33
|
+
autoplay,
|
|
34
|
+
videoWidth,
|
|
35
|
+
videoHeight,
|
|
36
|
+
muted
|
|
37
|
+
} = videoEl;
|
|
38
|
+
|
|
39
|
+
const width = videoEl.clientWidth;
|
|
40
|
+
const height = videoEl.clientHeight;
|
|
41
|
+
|
|
42
|
+
const info = {
|
|
43
|
+
type : 'html5',
|
|
44
|
+
isLive : this.isLive(),
|
|
45
|
+
version : this.getPlayerVersion() || 'html5',
|
|
46
|
+
streamType : this.getStreamType(),
|
|
47
|
+
streamUrl : this.getStreamURL(),
|
|
48
|
+
duration : duration,
|
|
49
|
+
autoplay : autoplay,
|
|
50
|
+
playerSoftware : this.playerSoftwareName,
|
|
51
|
+
videoWindowWidth : parseInt(width),
|
|
52
|
+
videoWindowHeight: parseInt(height),
|
|
53
|
+
currentVideoData:{
|
|
54
|
+
height : videoHeight,
|
|
55
|
+
width : videoWidth,
|
|
56
|
+
bitrate : this.analyticsBitrate_,
|
|
57
|
+
audioCodec : this.audioCodec_,
|
|
58
|
+
videoCodec : this.videoCodec_,
|
|
59
|
+
},
|
|
60
|
+
muted
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
this.eventCallback(Events.SOURCE_LOADED, info);
|
|
64
|
+
|
|
65
|
+
}, this);
|
|
66
|
+
} else {
|
|
67
|
+
this._initialize(mediaPlayer, videoEl);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_initialize(mediaPlayer, videoEl) {
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
* @member {dashjs.MediaPlayer}
|
|
75
|
+
*/
|
|
76
|
+
this.mediaPlayer = mediaPlayer;
|
|
77
|
+
|
|
78
|
+
this.setMediaElement(videoEl);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getPlayerVersion() {
|
|
82
|
+
return this.mediaPlayer.getVersion();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
isLive() {
|
|
86
|
+
// FIXME: Maybe use http://cdn.dashjs.org/latest/jsdoc/module-MediaPlayer.html#getLiveDelay__anchor
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @override
|
|
92
|
+
*/
|
|
93
|
+
getMIMEType() {
|
|
94
|
+
return MIMETypes.DASH;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @override
|
|
99
|
+
*/
|
|
100
|
+
getStreamURL() {
|
|
101
|
+
return this.mediaPlayer ? this.mediaPlayer.getSource() : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Implemented by sub-class to deliver current quality-level info
|
|
106
|
+
* specific to media-engine.
|
|
107
|
+
* @override
|
|
108
|
+
* @returns {QualityLevelInfo}
|
|
109
|
+
*/
|
|
110
|
+
getCurrentQualityLevelInfo() {
|
|
111
|
+
if (this.mediaPlayer) {
|
|
112
|
+
const videoBitrateInfoList = this.mediaPlayer.getBitrateInfoListFor('video');
|
|
113
|
+
const currentVideoQualityIndex = this.mediaPlayer.getQualityFor('video');
|
|
114
|
+
const currentVideoQuality = videoBitrateInfoList[currentVideoQualityIndex];
|
|
115
|
+
const currentVideoTrack = this.mediaPlayer.getCurrentTrackFor('video');
|
|
116
|
+
const currentAudioTrack = this.mediaPlayer.getCurrentTrackFor('audio');
|
|
117
|
+
|
|
118
|
+
const {width, height, bitrate} = currentVideoQuality;
|
|
119
|
+
let audioCodec = null;
|
|
120
|
+
let videoCodec = null;
|
|
121
|
+
|
|
122
|
+
if (currentVideoTrack) {
|
|
123
|
+
videoCodec = currentVideoTrack.codec.split('"').length > 0 ? currentVideoTrack.codec.split('"')[1] : currentVideoTrack.codec;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (currentAudioTrack) {
|
|
127
|
+
audioCodec = currentAudioTrack.codec.split('"').length > 0 ? currentAudioTrack.codec.split('"')[1] : currentAudioTrack.codec;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
width,
|
|
132
|
+
height,
|
|
133
|
+
bitrate,
|
|
134
|
+
audioCodec,
|
|
135
|
+
videoCodec,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|