@gcorevideo/player 2.30.2 → 2.30.3
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 +1 -1
- package/dist/index.css +353 -353
- package/dist/index.embed.js +8 -1
- package/dist/index.js +9 -2
- package/lib/plugins/media-control/MediaControl.d.ts +1 -0
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +9 -1
- package/package.json +1 -1
- package/src/plugins/media-control/MediaControl.ts +10 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/assets/vast-ads/style.scss +0 -112
- package/lib/plugins/vast-ads/VastAds.d.ts +0 -74
- package/lib/plugins/vast-ads/VastAds.d.ts.map +0 -1
- package/lib/plugins/vast-ads/VastAds.js +0 -693
- package/lib/plugins/vast-ads/loaderxml.d.ts +0 -32
- package/lib/plugins/vast-ads/loaderxml.d.ts.map +0 -1
- package/lib/plugins/vast-ads/loaderxml.js +0 -229
- package/lib/plugins/vast-ads/roll.d.ts +0 -60
- package/lib/plugins/vast-ads/roll.d.ts.map +0 -1
- package/lib/plugins/vast-ads/roll.js +0 -421
- package/lib/plugins/vast-ads/rollmanager.d.ts +0 -62
- package/lib/plugins/vast-ads/rollmanager.d.ts.map +0 -1
- package/lib/plugins/vast-ads/rollmanager.js +0 -357
- package/lib/plugins/vast-ads/sctemanager.d.ts +0 -18
- package/lib/plugins/vast-ads/sctemanager.d.ts.map +0 -1
- package/lib/plugins/vast-ads/sctemanager.js +0 -117
- package/lib/plugins/vast-ads/types.d.ts +0 -12
- package/lib/plugins/vast-ads/types.d.ts.map +0 -1
- package/lib/plugins/vast-ads/types.js +0 -1
- package/lib/plugins/vast-ads/urlhandler.d.ts +0 -4
- package/lib/plugins/vast-ads/urlhandler.d.ts.map +0 -1
- package/lib/plugins/vast-ads/urlhandler.js +0 -30
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts +0 -6
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +0 -1
- package/lib/plugins/vast-ads/xmlhttprequest.js +0 -40
- package/lib/plugins/vast-ads/xmlmerge.d.ts +0 -12
- package/lib/plugins/vast-ads/xmlmerge.d.ts.map +0 -1
- package/lib/plugins/vast-ads/xmlmerge.js +0 -83
- package/src/plugins/vast-ads/VastAds.ts +0 -919
- package/src/plugins/vast-ads/loaderxml.ts +0 -301
- package/src/plugins/vast-ads/roll.ts +0 -590
- package/src/plugins/vast-ads/rollmanager.ts +0 -447
- package/src/plugins/vast-ads/sctemanager.ts +0 -152
- package/src/plugins/vast-ads/types.ts +0 -20
- package/src/plugins/vast-ads/urlhandler.ts +0 -42
- package/src/plugins/vast-ads/xmlhttprequest.ts +0 -49
- package/src/plugins/vast-ads/xmlmerge.ts +0 -106
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
// import LogManager from '../../utils/LogManager';
|
|
2
|
-
import { $, Events, Log } from '@clappr/core';
|
|
3
|
-
import { reportError } from '@gcorevideo/utils';
|
|
4
|
-
import assert from 'assert';
|
|
5
|
-
export default class Roll extends Events {
|
|
6
|
-
mute;
|
|
7
|
-
core;
|
|
8
|
-
container;
|
|
9
|
-
$skipAd;
|
|
10
|
-
$muteIcon;
|
|
11
|
-
$areaClick;
|
|
12
|
-
_playback;
|
|
13
|
-
_volume;
|
|
14
|
-
_prevValueVolume;
|
|
15
|
-
_useDummyMp4Video = false;
|
|
16
|
-
firstRemaininTime = 0;
|
|
17
|
-
intervalTimer = null;
|
|
18
|
-
_isAdStartedTriggered;
|
|
19
|
-
extension;
|
|
20
|
-
_adsManager;
|
|
21
|
-
url = '';
|
|
22
|
-
// _events: Record<string, Function>;
|
|
23
|
-
constructor({ core, $skipAd, $muteIcon, $areaClick, mute, volume, prevVolume, }) {
|
|
24
|
-
super();
|
|
25
|
-
this.mute = mute;
|
|
26
|
-
this.core = core;
|
|
27
|
-
this.container = this.core.activeContainer;
|
|
28
|
-
this.$skipAd = $skipAd;
|
|
29
|
-
this.$muteIcon = $muteIcon;
|
|
30
|
-
this.$areaClick = $areaClick;
|
|
31
|
-
this._playback = this.core.activePlayback;
|
|
32
|
-
this._volume = volume;
|
|
33
|
-
this._prevValueVolume = prevVolume;
|
|
34
|
-
this._isAdStartedTriggered = false;
|
|
35
|
-
// this._events = {};
|
|
36
|
-
}
|
|
37
|
-
static _adContainer;
|
|
38
|
-
static _adDisplayContainer;
|
|
39
|
-
static _imaContainer;
|
|
40
|
-
static _contentElement = null;
|
|
41
|
-
static createAdDisplayContainer() {
|
|
42
|
-
Roll.createImaContainer();
|
|
43
|
-
assert('google' in window, 'Google IMA SDK not found');
|
|
44
|
-
Roll._adDisplayContainer = new window.google.ima.AdDisplayContainer(Roll._imaContainer, Roll._contentElement);
|
|
45
|
-
}
|
|
46
|
-
static createImaContainer() {
|
|
47
|
-
Roll.destroyImaContainer();
|
|
48
|
-
// IMA does not clean ad container when finished
|
|
49
|
-
// For the sake of simplicity, wrap into a <div> element
|
|
50
|
-
if (Roll._adContainer) {
|
|
51
|
-
Roll._imaContainer = document.createElement('div');
|
|
52
|
-
Roll._adContainer.appendChild(Roll._imaContainer);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
static destroyImaContainer() {
|
|
56
|
-
if (Roll._imaContainer && Roll._adContainer) {
|
|
57
|
-
Roll._adContainer.removeChild(Roll._imaContainer);
|
|
58
|
-
delete Roll._imaContainer;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
_onAdError(adErrorEvent) {
|
|
62
|
-
try {
|
|
63
|
-
const googleError = adErrorEvent.getError();
|
|
64
|
-
const error = new Error(googleError.getMessage() + ' ' + googleError.getErrorCode());
|
|
65
|
-
error.name = googleError.getType();
|
|
66
|
-
// LogManager.exception(error);
|
|
67
|
-
reportError(error);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
// LogManager.exception(error);
|
|
71
|
-
reportError(error);
|
|
72
|
-
}
|
|
73
|
-
Log.debug('Advertisement', 'advertisement error');
|
|
74
|
-
this._cleverContinueAd(true);
|
|
75
|
-
}
|
|
76
|
-
async _playAds() {
|
|
77
|
-
await Roll._adDisplayContainer.initialize();
|
|
78
|
-
try {
|
|
79
|
-
assert('google' in window, 'Google IMA SDK not found');
|
|
80
|
-
assert(Roll._contentElement, 'content element not found');
|
|
81
|
-
this._adsManager.init(Roll._contentElement.offsetWidth, Roll._contentElement.offsetHeight, window.google.ima.ViewMode.NORMAL);
|
|
82
|
-
this._adsManager.start();
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
// LogManager.exception(error);
|
|
86
|
-
reportError(error);
|
|
87
|
-
this._imaEvent('error', error);
|
|
88
|
-
this._playVideoContent();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
_setVolume(volume) {
|
|
92
|
-
try {
|
|
93
|
-
if (this._adsManager) {
|
|
94
|
-
this._adsManager.setVolume(volume / 100);
|
|
95
|
-
}
|
|
96
|
-
if (typeof this.core.mediaControl.setVolume === 'function') {
|
|
97
|
-
this.core.options.mute = !volume;
|
|
98
|
-
this.trigger('volume', {
|
|
99
|
-
volume,
|
|
100
|
-
mute: this.core.options.mute,
|
|
101
|
-
});
|
|
102
|
-
if (this.container.advertisement.type !== 'scteroll') {
|
|
103
|
-
this.core.mediaControl.setVolume(volume, true);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
if (volume) {
|
|
107
|
-
;
|
|
108
|
-
this.container.advertisement.isMuted = true;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
this.core.mediaControl.setVolume(volume, true);
|
|
112
|
-
this.container.advertisement.isMuted = false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
this._volume = volume;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
// LogManager.exception(error);
|
|
120
|
-
reportError(error);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
_playVideoContent() {
|
|
124
|
-
this.destroy();
|
|
125
|
-
this.trigger('advertisement_finish');
|
|
126
|
-
}
|
|
127
|
-
_hideControls() {
|
|
128
|
-
if (this.extension && this.extension.controls === '0') {
|
|
129
|
-
this.$skipAd.css({ opacity: 0, visibility: 'hidden' });
|
|
130
|
-
this.$muteIcon.css({ opacity: 0, visibility: 'hidden' });
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
this.$skipAd.css({ opacity: 1, visibility: 'visible' });
|
|
134
|
-
this.$muteIcon.css({ opacity: 1, visibility: 'visible' });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
_requestAd({ xml, url, extension, }) {
|
|
138
|
-
this.extension = extension;
|
|
139
|
-
assert('google' in window, 'Google IMA SDK not found');
|
|
140
|
-
const adsLoader = new window.google.ima.AdsLoader(Roll._adDisplayContainer);
|
|
141
|
-
adsLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, (e) => {
|
|
142
|
-
this._onAdsManagerLoaded(e);
|
|
143
|
-
});
|
|
144
|
-
adsLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR, (e) => {
|
|
145
|
-
this._onAdError(e);
|
|
146
|
-
});
|
|
147
|
-
const adsRequest = new window.google.ima.AdsRequest();
|
|
148
|
-
if (xml) {
|
|
149
|
-
adsRequest.adTagUrl = '';
|
|
150
|
-
adsRequest.adsResponse = xml;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
if (url) {
|
|
154
|
-
adsRequest.adTagUrl = url;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
throw 'no ad url';
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
this.url = url;
|
|
161
|
-
assert(Roll._contentElement, 'content element not found');
|
|
162
|
-
adsRequest.linearAdSlotWidth = Roll._contentElement.offsetWidth;
|
|
163
|
-
adsRequest.linearAdSlotHeight = Roll._contentElement.offsetHeight;
|
|
164
|
-
adsRequest.nonLinearAdSlotWidth = Roll._contentElement.offsetWidth;
|
|
165
|
-
adsRequest.nonLinearAdSlotHeight = Roll._contentElement.offsetHeight;
|
|
166
|
-
adsLoader.requestAds(adsRequest);
|
|
167
|
-
}
|
|
168
|
-
playerResize() {
|
|
169
|
-
assert(Roll._contentElement, 'content element not found');
|
|
170
|
-
assert('google' in window, 'Google IMA SDK not found');
|
|
171
|
-
this._adsManager &&
|
|
172
|
-
this._adsManager.resize(Roll._contentElement.offsetWidth, Roll._contentElement.offsetHeight, window.google.ima.ViewMode.NORMAL);
|
|
173
|
-
}
|
|
174
|
-
_onAdsManagerLoaded(adsManagerLoadedEvent) {
|
|
175
|
-
assert('google' in window, 'Google IMA SDK not found');
|
|
176
|
-
const adsRenderingSettings = new window.google.ima.AdsRenderingSettings();
|
|
177
|
-
adsRenderingSettings.loadVideoTimeout = process.env.MINIMIZE ? 4000 : 8000;
|
|
178
|
-
adsRenderingSettings.bitrate = 100000;
|
|
179
|
-
// Plugin will handle playback state when ad has completed
|
|
180
|
-
this._adsManager = adsManagerLoadedEvent.getAdsManager(Roll._contentElement, adsRenderingSettings);
|
|
181
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED, () => {
|
|
182
|
-
if (this.mute) {
|
|
183
|
-
this._setVolume(0);
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
this._setVolume(this._volume);
|
|
187
|
-
}
|
|
188
|
-
this.changeIconVolume();
|
|
189
|
-
});
|
|
190
|
-
this._adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR, (e) => {
|
|
191
|
-
const adType = this.container.advertisement.type;
|
|
192
|
-
if (!((adType === 'middleroll' || adType === 'repeatableroll') &&
|
|
193
|
-
!this._playback.isPlaying())) {
|
|
194
|
-
this._onAdError(e);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED, () => {
|
|
198
|
-
this._imaEvent('content_resume_requested');
|
|
199
|
-
});
|
|
200
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED, () => {
|
|
201
|
-
this._imaEvent('content_pause_requested');
|
|
202
|
-
this._triggerStartAd(this.url);
|
|
203
|
-
});
|
|
204
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.CLICK, () => {
|
|
205
|
-
this._imaEvent('click');
|
|
206
|
-
});
|
|
207
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.IMPRESSION, () => {
|
|
208
|
-
this._imaEvent('impression');
|
|
209
|
-
});
|
|
210
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED, (adEvent) => {
|
|
211
|
-
this._triggerStartAd(this.url);
|
|
212
|
-
this.trigger('advertisement_played');
|
|
213
|
-
const ad = adEvent.getAd();
|
|
214
|
-
try {
|
|
215
|
-
assert(Roll._contentElement, 'content element not found');
|
|
216
|
-
assert('google' in window, 'Google IMA SDK not found');
|
|
217
|
-
this._adsManager &&
|
|
218
|
-
this._adsManager.resize(Roll._contentElement.offsetWidth, Roll._contentElement.offsetHeight, window.google.ima.ViewMode.NORMAL);
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
// LogManager.exception(error);
|
|
222
|
-
reportError(error);
|
|
223
|
-
}
|
|
224
|
-
if (this.mute) {
|
|
225
|
-
this._setVolume(0);
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
this._setVolume(this._volume);
|
|
229
|
-
}
|
|
230
|
-
if (ad.isLinear()) {
|
|
231
|
-
// For a linear ad, a timer can be started to poll for
|
|
232
|
-
// the remaining time.
|
|
233
|
-
this.intervalTimer = setInterval(() => {
|
|
234
|
-
this._remainingTime(ad);
|
|
235
|
-
}, 300); // every 300ms
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.FIRST_QUARTILE, () => {
|
|
239
|
-
this._imaEvent('first_quartile');
|
|
240
|
-
});
|
|
241
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.MIDPOINT, () => {
|
|
242
|
-
this._imaEvent('midpoint');
|
|
243
|
-
});
|
|
244
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.THIRD_QUARTILE, () => {
|
|
245
|
-
this._imaEvent('third_quartile');
|
|
246
|
-
});
|
|
247
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE, () => {
|
|
248
|
-
this._imaEvent('complete');
|
|
249
|
-
this._useDummyMp4Video = false;
|
|
250
|
-
});
|
|
251
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED, () => {
|
|
252
|
-
this._imaEvent('all_ads_completed');
|
|
253
|
-
this._cleverContinueAd();
|
|
254
|
-
this._useDummyMp4Video = false;
|
|
255
|
-
});
|
|
256
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.PAUSED, () => {
|
|
257
|
-
this._imaEvent('paused');
|
|
258
|
-
});
|
|
259
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.RESUMED, () => {
|
|
260
|
-
this._imaEvent('resumed');
|
|
261
|
-
});
|
|
262
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.SKIPPED, () => {
|
|
263
|
-
this._imaEvent('skipped');
|
|
264
|
-
if (this.extension && this.extension.skipAd) {
|
|
265
|
-
this._trackUrl(this.extension.skipAd);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.VOLUME_CHANGED, () => {
|
|
269
|
-
this._imaEvent('volume_change');
|
|
270
|
-
this.changeIconVolume();
|
|
271
|
-
});
|
|
272
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.VOLUME_MUTED, () => {
|
|
273
|
-
this._imaEvent('volume_muted');
|
|
274
|
-
this.changeIconVolume();
|
|
275
|
-
});
|
|
276
|
-
this._adsManager.addEventListener(window.google.ima.AdEvent.Type.USER_CLOSE, () => {
|
|
277
|
-
this._imaEvent('user_close');
|
|
278
|
-
});
|
|
279
|
-
if (this.mute) {
|
|
280
|
-
this._setVolume(0);
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
this._setVolume(this._volume);
|
|
284
|
-
}
|
|
285
|
-
this._setupOverlay();
|
|
286
|
-
}
|
|
287
|
-
_triggerStartAd(url) {
|
|
288
|
-
if (!this._isAdStartedTriggered) {
|
|
289
|
-
this._isAdStartedTriggered = true;
|
|
290
|
-
this.trigger('advertisement_started', {
|
|
291
|
-
url,
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
_remainingTime(ad) {
|
|
296
|
-
if (!ad || !this._adsManager) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const remainingTime = Math.abs(this._adsManager.getRemainingTime());
|
|
300
|
-
const duration = ad.getDuration() || ad.getMinSuggestedDuration();
|
|
301
|
-
if (!this.firstRemaininTime) {
|
|
302
|
-
this.firstRemaininTime = this._adsManager.getRemainingTime();
|
|
303
|
-
}
|
|
304
|
-
const shouldShowSkip = remainingTime < this.firstRemaininTime &&
|
|
305
|
-
this.extension.timeOffset > -1 &&
|
|
306
|
-
this.firstRemaininTime > this.extension.timeOffset &&
|
|
307
|
-
!(duration > 0 && Math.abs(duration) < this.extension.timeOffset);
|
|
308
|
-
if (!shouldShowSkip) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
this.$skipAd.show();
|
|
312
|
-
const offset = Math.round(this.extension.timeOffset -
|
|
313
|
-
Math.abs(this.firstRemaininTime - remainingTime));
|
|
314
|
-
if (offset > 0) {
|
|
315
|
-
this.$skipAd.addClass('skip-ad-time');
|
|
316
|
-
this.$skipAd.text(this.core.i18n.t('you_can_skip_ad') + ' ' + offset);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
this.$skipAd.removeClass('skip-ad-time');
|
|
320
|
-
this.$skipAd.text(this.core.i18n.t('skip_ad'));
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
_cleverContinueAd(error) {
|
|
324
|
-
try {
|
|
325
|
-
this.destroy();
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
// LogManager.exception(error);
|
|
329
|
-
reportError(error);
|
|
330
|
-
}
|
|
331
|
-
this.trigger('continue_ad', { error });
|
|
332
|
-
}
|
|
333
|
-
_imaEvent(eventName, e) {
|
|
334
|
-
$.isFunction(this._events[eventName]) &&
|
|
335
|
-
this._events[eventName](e);
|
|
336
|
-
}
|
|
337
|
-
changeIconVolume() {
|
|
338
|
-
if (!this._adsManager) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
this.$muteIcon.show();
|
|
342
|
-
if (this._adsManager.getVolume() === 0) {
|
|
343
|
-
if (!this._volume && this._adsManager.getVolume()) {
|
|
344
|
-
this._volume = this._adsManager.getVolume() * 100;
|
|
345
|
-
}
|
|
346
|
-
this.$muteIcon.find('.mute-off-ad-icon').show();
|
|
347
|
-
this.$muteIcon.find('.mute-on-ad-icon').hide();
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
this._volume = this._adsManager.getVolume() * 100;
|
|
351
|
-
this.$muteIcon.find('.mute-on-ad-icon').show();
|
|
352
|
-
this.$muteIcon.find('.mute-off-ad-icon').hide();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
_setupOverlay() {
|
|
356
|
-
this.$muteIcon.off('click');
|
|
357
|
-
this.$skipAd.off('click');
|
|
358
|
-
this.$areaClick.off('click');
|
|
359
|
-
this.$muteIcon.off();
|
|
360
|
-
this.$skipAd.off();
|
|
361
|
-
this.$areaClick.off();
|
|
362
|
-
this.$muteIcon.on('click', () => {
|
|
363
|
-
if (this._adsManager) {
|
|
364
|
-
if (this._adsManager.getVolume() === 0) {
|
|
365
|
-
this._setVolume(this._prevValueVolume ? this._prevValueVolume : this._volume);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
this._setVolume(0);
|
|
369
|
-
}
|
|
370
|
-
this.changeIconVolume();
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
this.$skipAd.on('click', () => {
|
|
374
|
-
if (this.extension.skipEvents) {
|
|
375
|
-
this._trackUrls(this.extension.skipEvents);
|
|
376
|
-
}
|
|
377
|
-
if (this.extension.progressEvents) {
|
|
378
|
-
this._trackUrls(this.extension.progressEvents);
|
|
379
|
-
}
|
|
380
|
-
if (this.extension && this.extension.skipAd) {
|
|
381
|
-
this._trackUrl(this.extension.skipAd);
|
|
382
|
-
}
|
|
383
|
-
this._adsManager.stop();
|
|
384
|
-
console.warn('skip ad');
|
|
385
|
-
});
|
|
386
|
-
if (this.extension.clickThrough) {
|
|
387
|
-
this.$areaClick.show();
|
|
388
|
-
this.$areaClick.on('click', () => {
|
|
389
|
-
window.open(this.extension.clickThrough, '_blank');
|
|
390
|
-
console.warn(this.extension.clickTrackings);
|
|
391
|
-
if (this.extension.clickTrackings.length) {
|
|
392
|
-
this._trackUrls(this.extension.clickTrackings);
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
this._hideControls();
|
|
397
|
-
this._playAds();
|
|
398
|
-
}
|
|
399
|
-
_trackUrls(urls) {
|
|
400
|
-
for (let i = 0; i < urls.length; i++) {
|
|
401
|
-
this._trackUrl(urls[i]);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
_trackUrl(url) {
|
|
405
|
-
if (url) {
|
|
406
|
-
const i = new Image();
|
|
407
|
-
i.src = url;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
destroy() {
|
|
411
|
-
if (this.intervalTimer) {
|
|
412
|
-
clearInterval(this.intervalTimer);
|
|
413
|
-
this.intervalTimer = null;
|
|
414
|
-
}
|
|
415
|
-
if (Roll._adDisplayContainer) {
|
|
416
|
-
if (this._adsManager) {
|
|
417
|
-
this._adsManager.destroy();
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Core, Events } from '@clappr/core';
|
|
2
|
-
import { ZeptoResult } from '../../types.js';
|
|
3
|
-
import { AdRollDesc, AdRollType } from './types.js';
|
|
4
|
-
type CoreOptions = Record<string, unknown>;
|
|
5
|
-
export default class RollManager extends Events {
|
|
6
|
-
private core;
|
|
7
|
-
private options;
|
|
8
|
-
private $skipAd;
|
|
9
|
-
private $muteIcon;
|
|
10
|
-
private $areaClick;
|
|
11
|
-
private _adContainer;
|
|
12
|
-
private type;
|
|
13
|
-
private countRoll;
|
|
14
|
-
private volume;
|
|
15
|
-
private prevVolume;
|
|
16
|
-
private _allURLRequest;
|
|
17
|
-
private _container;
|
|
18
|
-
private container;
|
|
19
|
-
private _options;
|
|
20
|
-
private vastAdsOptions;
|
|
21
|
-
private _playback;
|
|
22
|
-
private _contentElement;
|
|
23
|
-
private _posterPlugin;
|
|
24
|
-
private _clickToPausePlugin;
|
|
25
|
-
private adTemplates;
|
|
26
|
-
private extension;
|
|
27
|
-
private firstRemaininTime;
|
|
28
|
-
private _imaContainer;
|
|
29
|
-
private isPlaying;
|
|
30
|
-
private loadXML;
|
|
31
|
-
private _pr;
|
|
32
|
-
private roll;
|
|
33
|
-
constructor(core: Core, options: CoreOptions, $skipAd: ZeptoResult, $muteIcon: ZeptoResult, $areaClick: ZeptoResult, _adContainer: HTMLElement, type: AdRollType, countRoll: number, volume: number, prevVolume: number);
|
|
34
|
-
private initializeRoll;
|
|
35
|
-
playerResize(_: {
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
}): void;
|
|
39
|
-
private onAdStarted;
|
|
40
|
-
onAdPlayed(): void;
|
|
41
|
-
private removeContainer;
|
|
42
|
-
private changeVolume;
|
|
43
|
-
_createImaContainer(): void;
|
|
44
|
-
_destroyImaContainer(): void;
|
|
45
|
-
setupRoll(): Promise<void>;
|
|
46
|
-
startAd(type: AdRollType, roll: AdRollDesc): Promise<void>;
|
|
47
|
-
_disableControls(): void;
|
|
48
|
-
private parseAdUrl;
|
|
49
|
-
paramsUrl(url: string): string;
|
|
50
|
-
loadAd(url: string): Promise<void>;
|
|
51
|
-
_onAdError(adErrorEvent: any): void;
|
|
52
|
-
_imaEvent(eventName: string, e: any): void;
|
|
53
|
-
/**
|
|
54
|
-
* определяет, что дальше будет запускаться реклама или контент
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
_cleverContinueAd(data: any): Promise<void>;
|
|
58
|
-
_playVideoContent(): void;
|
|
59
|
-
destroyRoll(): void;
|
|
60
|
-
}
|
|
61
|
-
export {};
|
|
62
|
-
//# sourceMappingURL=rollmanager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollmanager.d.ts","sourceRoot":"","sources":["../../../src/plugins/vast-ads/rollmanager.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EACJ,MAAM,EAMP,MAAM,cAAc,CAAA;AAMrB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAc,UAAU,EAAkB,MAAM,YAAY,CAAA;AAE/E,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAI1C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;IAqC3C,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,UAAU;IA7CpB,OAAO,CAAC,cAAc,CAAQ;IAE9B,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,SAAS,CAAW;IAE5B,OAAO,CAAC,QAAQ,CAAa;IAE7B,OAAO,CAAC,cAAc,CAAgB;IAEtC,OAAO,CAAC,SAAS,CAAU;IAE3B,OAAO,CAAC,eAAe,CAAkB;IAEzC,OAAO,CAAC,aAAa,CAAmB;IAExC,OAAO,CAAC,mBAAmB,CAAiB;IAE5C,OAAO,CAAC,WAAW,CAA4B;IAI/C,OAAO,CAAC,SAAS,CAA6B;IAE9C,OAAO,CAAC,iBAAiB,CAAI;IAE7B,OAAO,CAAC,aAAa,CAA2B;IAEhD,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,OAAO,CAAyB;IAExC,OAAO,CAAC,GAAG,CAAQ;IAEnB,OAAO,CAAC,IAAI,CAAoB;gBAGtB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,WAAW,EACtB,UAAU,EAAE,WAAW,EACvB,YAAY,EAAE,WAAW,EACzB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM;IAqB5B,OAAO,CAAC,cAAc;IAqCtB,YAAY,CAAC,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAMjD,OAAO,CAAC,WAAW;IAInB,UAAU;IAIV,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,YAAY;IAUpB,mBAAmB;IAUnB,oBAAoB;IAOd,SAAS;IAkCT,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU;IAmDhD,gBAAgB;IAOhB,OAAO,CAAC,UAAU;IAQlB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAsCxB,MAAM,CAAC,GAAG,EAAE,MAAM;IAgExB,UAAU,CAAC,YAAY,EAAE,GAAG;IAmB5B,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG;IAKnC;;;OAGG;IACG,iBAAiB,CAAC,IAAI,EAAE,GAAG;IAkBjC,iBAAiB;IAejB,WAAW;CASZ"}
|