@gcorevideo/player 2.28.24 → 2.28.26
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 +45 -32
- package/dist/index.css +305 -305
- package/dist/index.embed.js +119 -40
- package/dist/index.js +255 -124
- package/lib/Player.d.ts.map +1 -1
- package/lib/index.core.d.ts +1 -1
- package/lib/index.core.d.ts.map +1 -1
- package/lib/index.core.js +1 -1
- package/lib/index.plugins.d.ts +34 -34
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +34 -34
- package/lib/playback/dash-playback/DashPlayback.d.ts +4 -0
- package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.js +7 -0
- package/lib/playback/types.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +3 -1
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/speedtest/index.js +9 -5
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/utils.d.ts +2 -2
- package/lib/plugins/clips/utils.d.ts.map +1 -1
- package/lib/plugins/cmcd-config/CmcdConfig.js +1 -1
- package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -1
- package/lib/plugins/google-analytics/GoogleAnalytics.js +10 -3
- package/lib/plugins/kibo/index.d.ts.map +1 -1
- package/lib/plugins/kibo/index.js +69 -20
- package/lib/plugins/level-selector/QualityLevels.js +2 -2
- package/lib/plugins/logo/Logo.d.ts.map +1 -1
- package/lib/plugins/logo/Logo.js +19 -15
- package/lib/plugins/logo/utils/index.d.ts.map +1 -1
- package/lib/plugins/logo/utils/index.js +11 -7
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
- package/lib/plugins/multi-camera/MultiCamera.js +42 -20
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
- package/lib/plugins/picture-in-picture/PictureInPicture.js +3 -2
- package/lib/plugins/share/Share.d.ts.map +1 -1
- package/lib/plugins/share/Share.js +17 -12
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.d.ts +2 -0
- package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.js +25 -5
- package/lib/plugins/thumbnails/Thumbnails.js +2 -3
- package/lib/plugins/thumbnails/utils.d.ts.map +1 -1
- package/lib/plugins/utils/fullscreen.d.ts.map +1 -1
- package/lib/plugins/utils.d.ts.map +1 -1
- package/lib/plugins/utils.js +1 -1
- package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -1
- package/lib/plugins/vast-ads/VastAds.js +2 -1
- package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -1
- package/lib/plugins/vast-ads/loaderxml.js +8 -5
- package/lib/plugins/vast-ads/roll.d.ts +2 -2
- package/lib/plugins/vast-ads/roll.d.ts.map +1 -1
- package/lib/plugins/vast-ads/roll.js +16 -10
- package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -1
- package/lib/plugins/vast-ads/rollmanager.js +17 -7
- package/lib/plugins/vast-ads/sctemanager.d.ts +1 -1
- package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -1
- package/lib/plugins/vast-ads/sctemanager.js +6 -5
- package/lib/plugins/vast-ads/types.d.ts.map +1 -1
- package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -1
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -1
- package/lib/plugins/vast-ads/xmlhttprequest.js +3 -2
- package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -1
- package/lib/plugins/vast-ads/xmlmerge.js +4 -3
- package/lib/types.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/clickaway.d.ts.map +1 -1
- package/lib/utils/mediaSources.d.ts.map +1 -1
- package/lib/utils/mediaSources.js +1 -3
- package/lib/utils/types.d.ts.map +1 -1
- package/lib/version.js +2 -2
- package/package.json +2 -2
- package/src/Player.ts +10 -10
- package/src/__tests__/Player.test.ts +33 -10
- package/src/index.core.ts +9 -1
- package/src/index.plugins.ts +35 -35
- package/src/playback/__tests__/HTML5Video.test.ts +10 -4
- package/src/playback/dash-playback/DashPlayback.ts +8 -0
- package/src/playback/dash-playback/__tests__/DashPlayback.test.ts +10 -38
- package/src/playback/hls-playback/__tests__/HlsPlayback.test.ts +12 -45
- package/src/playback/types.ts +0 -1
- package/src/playback.types.ts +1 -2
- package/src/plugins/audio-selector/AudioTracks.ts +1 -1
- package/src/plugins/audio-selector/__tests__/AudioTracks.test.ts +30 -11
- package/src/plugins/bottom-gear/BottomGear.ts +3 -2
- package/src/plugins/clappr-nerd-stats/NerdStats.ts +1 -1
- package/src/plugins/clappr-nerd-stats/speedtest/index.ts +104 -82
- package/src/plugins/clappr-nerd-stats/speedtest/types.ts +3 -3
- package/src/plugins/clappr-nerd-stats/utils.ts +2 -2
- package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +30 -18
- package/src/plugins/clips/utils.ts +5 -1
- package/src/plugins/cmcd-config/CmcdConfig.ts +1 -1
- package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +21 -15
- package/src/plugins/favicon/Favicon.ts +73 -49
- package/src/plugins/google-analytics/GoogleAnalytics.ts +93 -58
- package/src/plugins/kibo/index.ts +183 -109
- package/src/plugins/level-selector/QualityLevels.ts +2 -2
- package/src/plugins/logo/Logo.ts +134 -105
- package/src/plugins/logo/utils/index.ts +27 -20
- package/src/plugins/media-control/MediaControl.ts +12 -6
- package/src/plugins/multi-camera/MultiCamera.ts +218 -157
- package/src/plugins/picture-in-picture/PictureInPicture.ts +41 -37
- package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +25 -11
- package/src/plugins/poster/__tests__/Poster.test.ts +8 -9
- package/src/plugins/share/Share.ts +85 -60
- package/src/plugins/skip-time/SkipTime.ts +5 -1
- package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +8 -5
- package/src/plugins/subtitles/ClosedCaptions.ts +30 -6
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +2 -3
- package/src/plugins/thumbnails/Thumbnails.ts +22 -21
- package/src/plugins/thumbnails/__tests__/Thumbnails.test.ts +14 -7
- package/src/plugins/thumbnails/utils.ts +3 -1
- package/src/plugins/typings/globals.d.ts +7 -7
- package/src/plugins/typings/workers.d.ts +3 -3
- package/src/plugins/utils/fullscreen.ts +2 -2
- package/src/plugins/utils.ts +17 -13
- package/src/plugins/vast-ads/VastAds.ts +4 -5
- package/src/plugins/vast-ads/loaderxml.ts +142 -101
- package/src/plugins/vast-ads/roll.ts +381 -284
- package/src/plugins/vast-ads/rollmanager.ts +214 -170
- package/src/plugins/vast-ads/sctemanager.ts +66 -48
- package/src/plugins/vast-ads/types.ts +15 -9
- package/src/plugins/vast-ads/urlhandler.ts +18 -13
- package/src/plugins/vast-ads/xmlhttprequest.ts +25 -20
- package/src/plugins/vast-ads/xmlmerge.ts +42 -32
- package/src/plugins/video360/VRControls.js +50 -42
- package/src/plugins/video360/VREffect.js +298 -206
- package/src/plugins/video360/Video360.js +553 -423
- package/src/plugins/video360/orbit-oriention-controls.js +526 -421
- package/src/plugins/video360/utils.js +18 -18
- package/src/types.ts +5 -3
- package/src/typings/@clappr/core/error_mixin.d.ts +9 -9
- package/src/typings/@clappr/core/index.d.ts +1 -3
- package/src/typings/@clappr/core/playback.d.ts +3 -3
- package/src/typings/@clappr/index.d.ts +1 -1
- package/src/typings/globals.d.ts +15 -15
- package/src/utils/__tests__/mediaSources.test.ts +42 -26
- package/src/utils/clickaway.ts +24 -24
- package/src/utils/errors.ts +2 -2
- package/src/utils/mediaSources.ts +5 -4
- package/src/utils/types.ts +1 -1
- package/src/version.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,51 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import {
|
|
2
|
+
$,
|
|
3
|
+
Browser,
|
|
4
|
+
Container,
|
|
5
|
+
ContainerPlugin,
|
|
6
|
+
Core,
|
|
7
|
+
Events,
|
|
8
|
+
HTML5Video,
|
|
9
|
+
Log,
|
|
10
|
+
Playback,
|
|
11
|
+
UIContainerPlugin,
|
|
12
|
+
Utils,
|
|
13
|
+
} from '@clappr/core'
|
|
14
|
+
import { reportError } from '@gcorevideo/utils'
|
|
15
|
+
import assert from 'assert'
|
|
16
|
+
|
|
17
|
+
import LoaderXML from './loaderxml.js'
|
|
18
|
+
import Roll from './roll.js'
|
|
19
|
+
import { ZeptoResult } from '../../types.js'
|
|
20
|
+
import { AdRollDesc, AdRollItem, AdRollType, VastAdsOptions } from './types.js'
|
|
21
|
+
|
|
22
|
+
type CoreOptions = Record<string, unknown>
|
|
23
|
+
|
|
24
|
+
type ExtensionData = Record<string, unknown>
|
|
13
25
|
|
|
14
26
|
export default class RollManager extends Events {
|
|
15
|
-
private _allURLRequest = false
|
|
27
|
+
private _allURLRequest = false
|
|
16
28
|
|
|
17
|
-
private _container: Container
|
|
18
|
-
private container: Container
|
|
29
|
+
private _container: Container
|
|
30
|
+
private container: Container
|
|
19
31
|
|
|
20
|
-
private _options: CoreOptions
|
|
32
|
+
private _options: CoreOptions
|
|
21
33
|
|
|
22
|
-
private vastAdsOptions: VastAdsOptions
|
|
34
|
+
private vastAdsOptions: VastAdsOptions
|
|
23
35
|
|
|
24
|
-
private _playback: Playback
|
|
36
|
+
private _playback: Playback
|
|
25
37
|
|
|
26
|
-
private _contentElement: HTMLMediaElement
|
|
38
|
+
private _contentElement: HTMLMediaElement
|
|
27
39
|
|
|
28
|
-
private _posterPlugin: UIContainerPlugin
|
|
40
|
+
private _posterPlugin: UIContainerPlugin
|
|
29
41
|
|
|
30
|
-
private _clickToPausePlugin: ContainerPlugin
|
|
42
|
+
private _clickToPausePlugin: ContainerPlugin
|
|
31
43
|
|
|
32
|
-
private adTemplates: AdRollItem[] | null = null
|
|
44
|
+
private adTemplates: AdRollItem[] | null = null
|
|
33
45
|
|
|
34
46
|
// private _adDisplayContainer: HTMLElement | null = null;
|
|
35
47
|
|
|
36
|
-
private extension: ExtensionData | null = null
|
|
48
|
+
private extension: ExtensionData | null = null
|
|
37
49
|
|
|
38
|
-
private firstRemaininTime = 0
|
|
50
|
+
private firstRemaininTime = 0
|
|
39
51
|
|
|
40
|
-
private _imaContainer: HTMLElement | null = null
|
|
52
|
+
private _imaContainer: HTMLElement | null = null
|
|
41
53
|
|
|
42
|
-
private isPlaying = false
|
|
54
|
+
private isPlaying = false
|
|
43
55
|
|
|
44
|
-
private loadXML: LoaderXML | null = null
|
|
56
|
+
private loadXML: LoaderXML | null = null
|
|
45
57
|
|
|
46
|
-
private _pr: number
|
|
58
|
+
private _pr: number
|
|
47
59
|
|
|
48
|
-
private roll: Roll | null = null
|
|
60
|
+
private roll: Roll | null = null
|
|
49
61
|
|
|
50
62
|
constructor(
|
|
51
63
|
private core: Core,
|
|
@@ -57,28 +69,36 @@ export default class RollManager extends Events {
|
|
|
57
69
|
private type: AdRollType,
|
|
58
70
|
private countRoll: number,
|
|
59
71
|
private volume: number,
|
|
60
|
-
private prevVolume: number
|
|
72
|
+
private prevVolume: number,
|
|
61
73
|
) {
|
|
62
|
-
super()
|
|
63
|
-
this._options = options
|
|
64
|
-
this.vastAdsOptions = this._options.vastAds as any
|
|
65
|
-
this.container = this.core.activeContainer
|
|
66
|
-
this._container = this.container
|
|
74
|
+
super()
|
|
75
|
+
this._options = options
|
|
76
|
+
this.vastAdsOptions = this._options.vastAds as any
|
|
77
|
+
this.container = this.core.activeContainer
|
|
78
|
+
this._container = this.container
|
|
67
79
|
// this.countRoll = countRoll || 0;
|
|
68
|
-
this.$skipAd = $skipAd
|
|
69
|
-
this.type = type
|
|
70
|
-
this.$muteIcon = $muteIcon
|
|
71
|
-
this.$areaClick = $areaClick
|
|
72
|
-
this._playback = this.core.activePlayback
|
|
73
|
-
this._contentElement = this._playback.el as HTMLMediaElement
|
|
74
|
-
this._posterPlugin = this._container.getPlugin('poster')
|
|
75
|
-
this._clickToPausePlugin = this._container.getPlugin('click_to_pause')
|
|
76
|
-
this._adContainer = _adContainer
|
|
77
|
-
this._events = {}
|
|
78
|
-
this._pr = Math.floor(Math.random() * 1000000)
|
|
80
|
+
this.$skipAd = $skipAd
|
|
81
|
+
this.type = type
|
|
82
|
+
this.$muteIcon = $muteIcon
|
|
83
|
+
this.$areaClick = $areaClick
|
|
84
|
+
this._playback = this.core.activePlayback
|
|
85
|
+
this._contentElement = this._playback.el as HTMLMediaElement
|
|
86
|
+
this._posterPlugin = this._container.getPlugin('poster')
|
|
87
|
+
this._clickToPausePlugin = this._container.getPlugin('click_to_pause')
|
|
88
|
+
this._adContainer = _adContainer
|
|
89
|
+
this._events = {}
|
|
90
|
+
this._pr = Math.floor(Math.random() * 1000000)
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
private initializeRoll({
|
|
93
|
+
private initializeRoll({
|
|
94
|
+
xml,
|
|
95
|
+
url,
|
|
96
|
+
extension,
|
|
97
|
+
}: {
|
|
98
|
+
xml: any
|
|
99
|
+
url: string
|
|
100
|
+
extension: any
|
|
101
|
+
}) {
|
|
82
102
|
try {
|
|
83
103
|
this.roll = new Roll({
|
|
84
104
|
core: this.core,
|
|
@@ -87,46 +107,46 @@ export default class RollManager extends Events {
|
|
|
87
107
|
$areaClick: this.$areaClick,
|
|
88
108
|
mute: !!this.options.mute,
|
|
89
109
|
volume: this.volume,
|
|
90
|
-
prevVolume: this.prevVolume
|
|
91
|
-
})
|
|
110
|
+
prevVolume: this.prevVolume,
|
|
111
|
+
})
|
|
92
112
|
// @ts-ignore
|
|
93
|
-
this.roll.on('volume', this.changeVolume.bind(this))
|
|
113
|
+
this.roll.on('volume', this.changeVolume.bind(this))
|
|
94
114
|
// @ts-ignore
|
|
95
|
-
this.roll.on('advertisement_started', this.onAdStarted.bind(this))
|
|
115
|
+
this.roll.on('advertisement_started', this.onAdStarted.bind(this))
|
|
96
116
|
// @ts-ignore
|
|
97
|
-
this.roll.on('advertisement_played', this.onAdPlayed.bind(this))
|
|
117
|
+
this.roll.on('advertisement_played', this.onAdPlayed.bind(this))
|
|
98
118
|
// @ts-ignore
|
|
99
|
-
this.roll.on('continue_ad', this._cleverContinueAd.bind(this))
|
|
119
|
+
this.roll.on('continue_ad', this._cleverContinueAd.bind(this))
|
|
100
120
|
// @ts-ignore
|
|
101
|
-
this.roll.on('advertisement_finish', this._playVideoContent.bind(this))
|
|
121
|
+
this.roll.on('advertisement_finish', this._playVideoContent.bind(this))
|
|
102
122
|
|
|
103
|
-
this.roll._requestAd({ xml, url, extension })
|
|
123
|
+
this.roll._requestAd({ xml, url, extension })
|
|
104
124
|
} catch (error) {
|
|
105
125
|
// LogManager.exception(error);
|
|
106
|
-
reportError(error)
|
|
126
|
+
reportError(error)
|
|
107
127
|
}
|
|
108
128
|
}
|
|
109
129
|
|
|
110
130
|
playerResize(_: { width: number; height: number }) {
|
|
111
131
|
if (this.roll) {
|
|
112
|
-
this.roll.playerResize()
|
|
132
|
+
this.roll.playerResize()
|
|
113
133
|
}
|
|
114
134
|
}
|
|
115
135
|
|
|
116
|
-
private onAdStarted(_: { url: string}) {
|
|
117
|
-
this.removeContainer()
|
|
136
|
+
private onAdStarted(_: { url: string }) {
|
|
137
|
+
this.removeContainer()
|
|
118
138
|
}
|
|
119
139
|
|
|
120
140
|
onAdPlayed() {
|
|
121
|
-
this.isPlaying = true
|
|
141
|
+
this.isPlaying = true
|
|
122
142
|
}
|
|
123
143
|
|
|
124
144
|
private removeContainer() {
|
|
125
|
-
this.trigger('advertisement_started')
|
|
145
|
+
this.trigger('advertisement_started')
|
|
126
146
|
}
|
|
127
147
|
|
|
128
|
-
private changeVolume(obj: { volume: number; mute: boolean
|
|
129
|
-
this.trigger('volume', obj)
|
|
148
|
+
private changeVolume(obj: { volume: number; mute: boolean }) {
|
|
149
|
+
this.trigger('volume', obj)
|
|
130
150
|
}
|
|
131
151
|
|
|
132
152
|
// private _createAdDisplayContainer() {
|
|
@@ -136,226 +156,246 @@ export default class RollManager extends Events {
|
|
|
136
156
|
// }
|
|
137
157
|
|
|
138
158
|
_createImaContainer() {
|
|
139
|
-
this._destroyImaContainer()
|
|
159
|
+
this._destroyImaContainer()
|
|
140
160
|
// IMA does not clean ad container when finished
|
|
141
161
|
// For the sake of simplicity, wrap into a <div> element
|
|
142
162
|
if (this._adContainer) {
|
|
143
|
-
this._imaContainer = document.createElement('div')
|
|
144
|
-
this._adContainer.appendChild(this._imaContainer)
|
|
163
|
+
this._imaContainer = document.createElement('div')
|
|
164
|
+
this._adContainer.appendChild(this._imaContainer)
|
|
145
165
|
}
|
|
146
166
|
}
|
|
147
167
|
|
|
148
168
|
_destroyImaContainer() {
|
|
149
169
|
if (this._imaContainer && this._adContainer) {
|
|
150
|
-
this._adContainer.removeChild(this._imaContainer)
|
|
151
|
-
this._imaContainer = null
|
|
170
|
+
this._adContainer.removeChild(this._imaContainer)
|
|
171
|
+
this._imaContainer = null
|
|
152
172
|
}
|
|
153
173
|
}
|
|
154
174
|
|
|
155
175
|
async setupRoll() {
|
|
156
176
|
// TODO: check if this is correct
|
|
157
|
-
const dataAd = this.vastAdsOptions[this.type] || { data: [] }
|
|
158
|
-
const { oneByOne = false } = dataAd
|
|
159
|
-
let rollList = dataAd.data
|
|
177
|
+
const dataAd = this.vastAdsOptions[this.type] || { data: [] }
|
|
178
|
+
const { oneByOne = false } = dataAd
|
|
179
|
+
let rollList = dataAd.data
|
|
160
180
|
|
|
161
181
|
if (this.type === 'middleroll') {
|
|
162
|
-
const currentStartTime = dataAd.data[this.countRoll].startTimePercent
|
|
182
|
+
const currentStartTime = dataAd.data[this.countRoll].startTimePercent
|
|
163
183
|
|
|
164
184
|
rollList = dataAd.data.filter((el) => {
|
|
165
185
|
if (el.startTimePercent === currentStartTime) {
|
|
166
|
-
return true
|
|
186
|
+
return true
|
|
167
187
|
}
|
|
168
|
-
})
|
|
188
|
+
})
|
|
169
189
|
}
|
|
170
190
|
if (this.type === 'repeatableroll') {
|
|
171
|
-
const currentStartTime = dataAd.data[this.countRoll].startTime
|
|
191
|
+
const currentStartTime = dataAd.data[this.countRoll].startTime
|
|
172
192
|
|
|
173
193
|
rollList = dataAd.data.filter((el) => {
|
|
174
194
|
if (el.startTime === currentStartTime) {
|
|
175
|
-
return true
|
|
195
|
+
return true
|
|
176
196
|
}
|
|
177
|
-
})
|
|
197
|
+
})
|
|
178
198
|
}
|
|
179
199
|
|
|
180
200
|
if (this.type === 'middleroll' || this.type === 'repeatableroll') {
|
|
181
|
-
this.trigger('change_counter', {
|
|
201
|
+
this.trigger('change_counter', {
|
|
202
|
+
type: this.type,
|
|
203
|
+
value: this.countRoll + rollList.length,
|
|
204
|
+
})
|
|
182
205
|
}
|
|
183
|
-
await this.startAd(this.type, { data: rollList, oneByOne })
|
|
206
|
+
await this.startAd(this.type, { data: rollList, oneByOne })
|
|
184
207
|
}
|
|
185
208
|
|
|
186
209
|
async startAd(type: AdRollType, roll: AdRollDesc) {
|
|
187
210
|
// TODO
|
|
188
211
|
// Player.player.trigger('advertisementWasStarted');
|
|
189
|
-
this.core.trigger('core:advertisement:start')
|
|
190
|
-
this.container.trigger('container:advertisement:start')
|
|
191
|
-
(this.container as any).advertisement = { type: type }
|
|
212
|
+
this.core.trigger('core:advertisement:start')
|
|
213
|
+
this.container.trigger('container:advertisement:start')
|
|
214
|
+
;(this.container as any).advertisement = { type: type }
|
|
192
215
|
if (type !== 'middleroll' && type !== 'repeatableroll') {
|
|
193
|
-
console.warn('disableControls')
|
|
194
|
-
setTimeout(() => this._disableControls(), 0)
|
|
216
|
+
console.warn('disableControls')
|
|
217
|
+
setTimeout(() => this._disableControls(), 0)
|
|
195
218
|
}
|
|
196
219
|
|
|
197
220
|
if (!this.adTemplates && roll) {
|
|
198
|
-
this.adTemplates = this.parseAdUrl(roll.data)
|
|
221
|
+
this.adTemplates = this.parseAdUrl(roll.data)
|
|
199
222
|
if (!this.adTemplates) {
|
|
200
|
-
this.trigger('disable_plugin', { type: this.type })
|
|
223
|
+
this.trigger('disable_plugin', { type: this.type })
|
|
201
224
|
|
|
202
|
-
return
|
|
225
|
+
return
|
|
203
226
|
}
|
|
204
227
|
}
|
|
205
228
|
if (type === 'preroll') {
|
|
206
229
|
if (Browser.isMobile) {
|
|
207
|
-
this._playback.consent(() => {})
|
|
230
|
+
this._playback.consent(() => {})
|
|
208
231
|
}
|
|
209
232
|
}
|
|
210
233
|
//чтобы реклама шла одна за другой
|
|
211
|
-
this._allURLRequest = !!roll.oneByOne
|
|
234
|
+
this._allURLRequest = !!roll.oneByOne
|
|
212
235
|
try {
|
|
213
|
-
const customPosterPlugin = this.container.getPlugin('poster')
|
|
236
|
+
const customPosterPlugin = this.container.getPlugin('poster')
|
|
214
237
|
|
|
215
|
-
customPosterPlugin.hidePlayButton()
|
|
238
|
+
customPosterPlugin.hidePlayButton()
|
|
216
239
|
} catch (error) {
|
|
217
240
|
// LogManager.exception(error);
|
|
218
|
-
reportError(error)
|
|
241
|
+
reportError(error)
|
|
219
242
|
}
|
|
220
243
|
|
|
221
244
|
if (!this.adTemplates?.length) {
|
|
222
|
-
this.trigger('advertisement_dont_play', { type: this.type })
|
|
245
|
+
this.trigger('advertisement_dont_play', { type: this.type })
|
|
223
246
|
|
|
224
|
-
return
|
|
247
|
+
return
|
|
225
248
|
}
|
|
226
|
-
Log.debug('Advertisement', 'advertisement will start')
|
|
249
|
+
Log.debug('Advertisement', 'advertisement will start')
|
|
227
250
|
try {
|
|
228
|
-
const adTemplate = this.adTemplates.shift()
|
|
251
|
+
const adTemplate = this.adTemplates.shift()
|
|
229
252
|
// @ts-ignore
|
|
230
|
-
await this.loadAd(adTemplate.url)
|
|
253
|
+
await this.loadAd(adTemplate.url)
|
|
231
254
|
} catch (error) {
|
|
232
255
|
// LogManager.exception(error);
|
|
233
|
-
reportError(error)
|
|
256
|
+
reportError(error)
|
|
234
257
|
}
|
|
235
258
|
}
|
|
236
259
|
|
|
237
260
|
_disableControls() {
|
|
238
|
-
this.container.disableMediaControl()
|
|
239
|
-
this._clickToPausePlugin?.disable()
|
|
261
|
+
this.container.disableMediaControl()
|
|
262
|
+
this._clickToPausePlugin?.disable()
|
|
240
263
|
// @ts-ignore
|
|
241
|
-
this._posterPlugin?.$playWrapper.hide()
|
|
264
|
+
this._posterPlugin?.$playWrapper.hide()
|
|
242
265
|
}
|
|
243
266
|
|
|
244
267
|
private parseAdUrl(arr: any): AdRollItem[] | null {
|
|
245
268
|
if (!Array.isArray(arr)) {
|
|
246
|
-
return null
|
|
269
|
+
return null
|
|
247
270
|
}
|
|
248
271
|
|
|
249
|
-
return arr.filter((el) => el.url)
|
|
272
|
+
return arr.filter((el) => el.url)
|
|
250
273
|
}
|
|
251
274
|
|
|
252
275
|
paramsUrl(url: string): string {
|
|
253
276
|
try {
|
|
254
|
-
url = url.replace(/\{width\}/g, this.container.$el.width())
|
|
255
|
-
url = url.replace(/\{height\}/g, this.container.$el.height())
|
|
256
|
-
url = url.replace(/\{pr\}/g, String(this._pr))
|
|
257
|
-
url = url.replace(
|
|
258
|
-
|
|
259
|
-
|
|
277
|
+
url = url.replace(/\{width\}/g, this.container.$el.width())
|
|
278
|
+
url = url.replace(/\{height\}/g, this.container.$el.height())
|
|
279
|
+
url = url.replace(/\{pr\}/g, String(this._pr))
|
|
280
|
+
url = url.replace(
|
|
281
|
+
/\{random\}/g,
|
|
282
|
+
String(Math.floor(Math.random() * 1000000)),
|
|
283
|
+
)
|
|
284
|
+
url = url.replace(/\{session_id\}/g, Utils.uniqueId(''))
|
|
285
|
+
url = url.replace(/\{start_delay\}/g, '0')
|
|
260
286
|
|
|
261
287
|
if (this.options.referer) {
|
|
262
|
-
url = url.replace(
|
|
288
|
+
url = url.replace(
|
|
289
|
+
new RegExp(/\{referer\}/g, 'g'),
|
|
290
|
+
String(this.options.referer ?? ''),
|
|
291
|
+
)
|
|
263
292
|
}
|
|
264
293
|
|
|
265
|
-
let playback = 1
|
|
294
|
+
let playback = 1
|
|
266
295
|
|
|
267
296
|
if (this.options.autoPlay && this.options.mute) {
|
|
268
|
-
playback = 2
|
|
297
|
+
playback = 2
|
|
269
298
|
}
|
|
270
299
|
|
|
271
300
|
if (!this.options.autoPlay) {
|
|
272
|
-
playback = 3
|
|
301
|
+
playback = 3
|
|
273
302
|
}
|
|
274
303
|
|
|
275
|
-
url = url.replace(/\{playback\}/g, String(playback))
|
|
304
|
+
url = url.replace(/\{playback\}/g, String(playback))
|
|
276
305
|
} catch (error) {
|
|
277
306
|
// LogManager.exception(error);
|
|
278
|
-
reportError(error)
|
|
307
|
+
reportError(error)
|
|
279
308
|
}
|
|
280
309
|
|
|
281
|
-
return url
|
|
310
|
+
return url
|
|
282
311
|
}
|
|
283
312
|
|
|
284
313
|
async loadAd(url: string) {
|
|
285
314
|
if (!url) {
|
|
286
|
-
return
|
|
315
|
+
return
|
|
287
316
|
}
|
|
288
317
|
try {
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
318
|
+
if (
|
|
319
|
+
!['middleroll', 'repeatableroll'].includes(
|
|
320
|
+
(this.container as any).advertisement.type,
|
|
321
|
+
)
|
|
322
|
+
) {
|
|
323
|
+
const spinnerPlugin = this.container.getPlugin('spinner')
|
|
324
|
+
|
|
325
|
+
spinnerPlugin?.show()
|
|
293
326
|
}
|
|
294
327
|
} catch (error) {
|
|
295
328
|
// LogManager.exception(error);
|
|
296
|
-
reportError(error)
|
|
329
|
+
reportError(error)
|
|
297
330
|
}
|
|
298
|
-
url = this.paramsUrl(url)
|
|
331
|
+
url = this.paramsUrl(url)
|
|
299
332
|
|
|
300
|
-
Roll._adContainer = this._adContainer
|
|
301
|
-
Roll._contentElement = this._contentElement
|
|
302
|
-
Roll.createAdDisplayContainer()
|
|
303
|
-
this.loadXML = new LoaderXML(url)
|
|
304
|
-
let data: ExtensionData
|
|
333
|
+
Roll._adContainer = this._adContainer
|
|
334
|
+
Roll._contentElement = this._contentElement
|
|
335
|
+
Roll.createAdDisplayContainer()
|
|
336
|
+
this.loadXML = new LoaderXML(url)
|
|
337
|
+
let data: ExtensionData
|
|
305
338
|
|
|
306
339
|
try {
|
|
307
|
-
data = await this.loadXML.startLoad()
|
|
340
|
+
data = await this.loadXML.startLoad()
|
|
308
341
|
} catch (error) {
|
|
309
342
|
// LogManager.exception(error);
|
|
310
|
-
reportError(error)
|
|
343
|
+
reportError(error)
|
|
311
344
|
if (this.adTemplates && this.adTemplates.length > 0) {
|
|
312
|
-
const adTemplate = this.adTemplates.shift()
|
|
345
|
+
const adTemplate = this.adTemplates.shift()
|
|
313
346
|
// @ts-ignore
|
|
314
|
-
await this.loadAd(adTemplate.url)
|
|
347
|
+
await this.loadAd(adTemplate.url)
|
|
315
348
|
} else {
|
|
316
|
-
const spinnerPlugin = this.container.getPlugin('spinner')
|
|
349
|
+
const spinnerPlugin = this.container.getPlugin('spinner')
|
|
317
350
|
|
|
318
|
-
spinnerPlugin?.hide()
|
|
319
|
-
this.trigger('advertisement_dont_play', { type: this.type })
|
|
351
|
+
spinnerPlugin?.hide()
|
|
352
|
+
this.trigger('advertisement_dont_play', { type: this.type })
|
|
320
353
|
}
|
|
321
354
|
|
|
322
|
-
return
|
|
355
|
+
return
|
|
323
356
|
}
|
|
324
357
|
try {
|
|
325
|
-
this.firstRemaininTime = 0
|
|
326
|
-
this.$muteIcon.hide()
|
|
327
|
-
this.$skipAd.hide()
|
|
358
|
+
this.firstRemaininTime = 0
|
|
359
|
+
this.$muteIcon.hide()
|
|
360
|
+
this.$skipAd.hide()
|
|
328
361
|
|
|
329
362
|
// this.volume = this._playback.volume;
|
|
330
|
-
assert(this._playback instanceof HTML5Video)
|
|
331
|
-
this.volume = (this._playback.el as HTMLMediaElement).volume
|
|
363
|
+
assert(this._playback instanceof HTML5Video)
|
|
364
|
+
this.volume = (this._playback.el as HTMLMediaElement).volume
|
|
332
365
|
} catch (error) {
|
|
333
366
|
// LogManager.exception(error);
|
|
334
|
-
reportError(error)
|
|
367
|
+
reportError(error)
|
|
335
368
|
}
|
|
336
|
-
this.extension = data
|
|
337
|
-
this.initializeRoll({
|
|
369
|
+
this.extension = data
|
|
370
|
+
this.initializeRoll({
|
|
371
|
+
xml: data.config,
|
|
372
|
+
url: String(data.url || url),
|
|
373
|
+
extension: data,
|
|
374
|
+
})
|
|
338
375
|
}
|
|
339
376
|
|
|
340
377
|
_onAdError(adErrorEvent: any) {
|
|
341
378
|
try {
|
|
342
|
-
const googleError = adErrorEvent.getError()
|
|
343
|
-
const error = new Error(
|
|
379
|
+
const googleError = adErrorEvent.getError()
|
|
380
|
+
const error = new Error(
|
|
381
|
+
googleError.getMessage() + ' ' + googleError.getErrorCode(),
|
|
382
|
+
)
|
|
344
383
|
|
|
345
|
-
error.name = googleError.getType()
|
|
384
|
+
error.name = googleError.getType()
|
|
346
385
|
// LogManager.exception(error);
|
|
347
|
-
reportError(error)
|
|
386
|
+
reportError(error)
|
|
348
387
|
} catch (error) {
|
|
349
388
|
// LogManager.exception(error);
|
|
350
|
-
reportError(error)
|
|
389
|
+
reportError(error)
|
|
351
390
|
}
|
|
352
|
-
Log.debug('Advertisement', 'advertisement error')
|
|
391
|
+
Log.debug('Advertisement', 'advertisement error')
|
|
353
392
|
|
|
354
|
-
this._cleverContinueAd(true)
|
|
393
|
+
this._cleverContinueAd(true)
|
|
355
394
|
}
|
|
356
395
|
|
|
357
396
|
_imaEvent(eventName: string, e: any) {
|
|
358
|
-
$.isFunction((this._events as any)[eventName]) &&
|
|
397
|
+
$.isFunction((this._events as any)[eventName]) &&
|
|
398
|
+
(this._events as any)[eventName](e)
|
|
359
399
|
}
|
|
360
400
|
|
|
361
401
|
/**
|
|
@@ -363,41 +403,45 @@ export default class RollManager extends Events {
|
|
|
363
403
|
*
|
|
364
404
|
*/
|
|
365
405
|
async _cleverContinueAd(data: any) {
|
|
366
|
-
this.destroyRoll()
|
|
367
|
-
const error = data.error
|
|
368
|
-
|
|
369
|
-
if (
|
|
370
|
-
|
|
406
|
+
this.destroyRoll()
|
|
407
|
+
const error = data.error
|
|
408
|
+
|
|
409
|
+
if (
|
|
410
|
+
(this._allURLRequest || error) &&
|
|
411
|
+
this.adTemplates &&
|
|
412
|
+
this.adTemplates.length > 0
|
|
413
|
+
) {
|
|
414
|
+
const adTemplate = this.adTemplates.shift()
|
|
371
415
|
// @ts-ignore
|
|
372
|
-
await this.loadAd(adTemplate.url)
|
|
416
|
+
await this.loadAd(adTemplate.url)
|
|
373
417
|
|
|
374
|
-
return
|
|
418
|
+
return
|
|
375
419
|
}
|
|
376
|
-
this._playVideoContent()
|
|
420
|
+
this._playVideoContent()
|
|
377
421
|
}
|
|
378
422
|
|
|
379
423
|
_playVideoContent() {
|
|
380
|
-
this.destroyRoll()
|
|
381
|
-
Roll.destroyImaContainer()
|
|
424
|
+
this.destroyRoll()
|
|
425
|
+
Roll.destroyImaContainer()
|
|
382
426
|
|
|
383
|
-
const spinnerPlugin = this.container.getPlugin('spinner')
|
|
427
|
+
const spinnerPlugin = this.container.getPlugin('spinner')
|
|
384
428
|
|
|
385
|
-
spinnerPlugin?.hide()
|
|
429
|
+
spinnerPlugin?.hide()
|
|
386
430
|
|
|
387
431
|
if (this.isPlaying) {
|
|
388
|
-
this.trigger('advertisement_finish', { type: this.type })
|
|
432
|
+
this.trigger('advertisement_finish', { type: this.type })
|
|
389
433
|
} else {
|
|
390
|
-
this.trigger('advertisement_dont_play', { type: this.type })
|
|
434
|
+
this.trigger('advertisement_dont_play', { type: this.type })
|
|
391
435
|
}
|
|
392
436
|
}
|
|
393
437
|
|
|
394
438
|
destroyRoll() {
|
|
395
439
|
if (!this.roll) {
|
|
396
|
-
return
|
|
440
|
+
return
|
|
397
441
|
}
|
|
398
442
|
// @ts-ignore
|
|
399
|
-
this.roll.off()
|
|
400
|
-
this.roll.destroy()
|
|
401
|
-
this.roll = null
|
|
443
|
+
this.roll.off()
|
|
444
|
+
this.roll.destroy()
|
|
445
|
+
this.roll = null
|
|
402
446
|
}
|
|
403
447
|
}
|