@gcorevideo/player 2.28.25 → 2.28.27
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 +166 -61
- package/dist/index.css +395 -395
- package/dist/index.embed.js +155 -66
- package/dist/index.js +355 -151
- 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/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.map +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.js +4 -3
- 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 +3 -3
- package/src/Player.ts +10 -10
- package/src/__tests__/Player.test.ts +33 -10
- package/src/index.core.ts +10 -1
- package/src/index.plugins.ts +35 -35
- package/src/playback/BasePlayback.ts +1 -1
- package/src/playback/__tests__/HTML5Video.test.ts +10 -4
- 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 +7 -5
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +0 -1
- 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,16 +1,16 @@
|
|
|
1
|
-
import { Events, Playback } from '@clappr/core'
|
|
2
|
-
import { Events as HlsEvents, FragChangedData } from 'hls.js'
|
|
1
|
+
import { Events, Playback } from '@clappr/core'
|
|
2
|
+
import { Events as HlsEvents, FragChangedData } from 'hls.js'
|
|
3
3
|
|
|
4
4
|
const OUT = 'out',
|
|
5
5
|
IN = 'in',
|
|
6
|
-
OUT_CONT = 'out_cont'
|
|
6
|
+
OUT_CONT = 'out_cont'
|
|
7
7
|
|
|
8
|
-
type CueResult = { kind?:
|
|
8
|
+
type CueResult = { kind?: 'in' | 'out' | 'out_cont'; duration?: number }
|
|
9
9
|
|
|
10
10
|
export default class SCTEManager extends Events {
|
|
11
|
-
private _playback: Playback | null = null
|
|
12
|
-
|
|
13
|
-
private _scteIsStarted = false
|
|
11
|
+
private _playback: Playback | null = null
|
|
12
|
+
|
|
13
|
+
private _scteIsStarted = false
|
|
14
14
|
|
|
15
15
|
set playback(value: Playback) {
|
|
16
16
|
if (this._playback) {
|
|
@@ -18,65 +18,82 @@ export default class SCTEManager extends Events {
|
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
if (this._playback._hls) {
|
|
20
20
|
// @ts-ignore
|
|
21
|
-
this._playback._hls.off(
|
|
21
|
+
this._playback._hls.off(
|
|
22
|
+
HlsEvents.FRAG_CHANGED,
|
|
23
|
+
this._onHlsFragChanged.bind(this),
|
|
24
|
+
)
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
this._playback.off(
|
|
26
|
+
|
|
27
|
+
this._playback.off(
|
|
28
|
+
Events.PLAYBACK_PLAY_INTENT,
|
|
29
|
+
this._subscribedHlsEvents,
|
|
30
|
+
this,
|
|
31
|
+
)
|
|
25
32
|
}
|
|
26
|
-
this._playback = value
|
|
33
|
+
this._playback = value
|
|
27
34
|
// @ts-ignore
|
|
28
35
|
if (!this._playback._hls) {
|
|
29
|
-
this._playback.once(
|
|
36
|
+
this._playback.once(
|
|
37
|
+
Events.PLAYBACK_PLAY_INTENT,
|
|
38
|
+
this._subscribedHlsEvents,
|
|
39
|
+
this,
|
|
40
|
+
)
|
|
30
41
|
} else {
|
|
31
|
-
this._subscribedHlsEvents()
|
|
42
|
+
this._subscribedHlsEvents()
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
get playback(): Playback | null {
|
|
36
|
-
return this._playback
|
|
47
|
+
return this._playback
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
_subscribedHlsEvents() {
|
|
40
51
|
// @ts-ignore
|
|
41
52
|
if (this._playback._hls) {
|
|
42
53
|
// @ts-ignore
|
|
43
|
-
this._playback._hls.off(
|
|
54
|
+
this._playback._hls.off(
|
|
55
|
+
HlsEvents.FRAG_CHANGED,
|
|
56
|
+
this._onHlsFragChanged.bind(this),
|
|
57
|
+
)
|
|
44
58
|
// @ts-ignore
|
|
45
|
-
this._playback._hls.on(
|
|
59
|
+
this._playback._hls.on(
|
|
60
|
+
HlsEvents.FRAG_CHANGED,
|
|
61
|
+
this._onHlsFragChanged.bind(this),
|
|
62
|
+
)
|
|
46
63
|
}
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
_onHlsFragChanged(_: HlsEvents.FRAG_CHANGED, data: FragChangedData) {
|
|
50
|
-
const { tagList } = data.frag
|
|
67
|
+
const { tagList } = data.frag
|
|
51
68
|
|
|
52
69
|
if (tagList) {
|
|
53
|
-
const cue = this._getCue(tagList)
|
|
70
|
+
const cue = this._getCue(tagList)
|
|
54
71
|
|
|
55
72
|
if (Object.keys(cue).length > 0) {
|
|
56
73
|
if (!this._scteIsStarted) {
|
|
57
74
|
if (cue.kind === OUT || cue.kind === OUT_CONT) {
|
|
58
|
-
this._scteIsStarted = true
|
|
59
|
-
console.warn('scteroll will be started')
|
|
75
|
+
this._scteIsStarted = true
|
|
76
|
+
console.warn('scteroll will be started')
|
|
60
77
|
this.trigger('startSCTERoll', {
|
|
61
|
-
duration: cue.duration
|
|
62
|
-
})
|
|
78
|
+
duration: cue.duration,
|
|
79
|
+
})
|
|
63
80
|
}
|
|
64
81
|
} else {
|
|
65
82
|
if (cue.kind === IN) {
|
|
66
|
-
console.warn('scteroll will be stopped')
|
|
67
|
-
this._stopScte()
|
|
83
|
+
console.warn('scteroll will be stopped')
|
|
84
|
+
this._stopScte()
|
|
68
85
|
}
|
|
69
86
|
}
|
|
70
87
|
} else {
|
|
71
|
-
this._stopScte()
|
|
88
|
+
this._stopScte()
|
|
72
89
|
}
|
|
73
90
|
}
|
|
74
91
|
}
|
|
75
92
|
|
|
76
93
|
_stopScte() {
|
|
77
94
|
if (this._scteIsStarted) {
|
|
78
|
-
this.trigger('stopSCTERoll')
|
|
79
|
-
this._scteIsStarted = false
|
|
95
|
+
this.trigger('stopSCTERoll')
|
|
96
|
+
this._scteIsStarted = false
|
|
80
97
|
}
|
|
81
98
|
}
|
|
82
99
|
|
|
@@ -84,51 +101,52 @@ export default class SCTEManager extends Events {
|
|
|
84
101
|
let cueResult: CueResult = {
|
|
85
102
|
kind: undefined,
|
|
86
103
|
duration: undefined,
|
|
87
|
-
}
|
|
104
|
+
}
|
|
88
105
|
|
|
89
106
|
for (let i = 0; i < tagList.length; i++) {
|
|
90
|
-
const infoSegment = tagList[i]
|
|
91
|
-
let kind:
|
|
92
|
-
let duration: number | undefined
|
|
107
|
+
const infoSegment = tagList[i]
|
|
108
|
+
let kind: 'in' | 'out' | 'out_cont' | undefined
|
|
109
|
+
let duration: number | undefined
|
|
93
110
|
|
|
94
111
|
infoSegment.forEach((info) => {
|
|
95
112
|
if (kind) {
|
|
96
113
|
if (kind === OUT) {
|
|
97
|
-
const dur = parseInt(info)
|
|
114
|
+
const dur = parseInt(info)
|
|
98
115
|
|
|
99
|
-
!isNaN(dur) && (duration = dur)
|
|
116
|
+
!isNaN(dur) && (duration = dur)
|
|
100
117
|
}
|
|
101
118
|
if (kind === OUT_CONT) {
|
|
102
|
-
const durString = info.match(/Duration=\d+/g)
|
|
119
|
+
const durString = info.match(/Duration=\d+/g)
|
|
103
120
|
|
|
104
121
|
if (durString) {
|
|
105
|
-
const durNumb = durString[0].match(/\d+/g)
|
|
122
|
+
const durNumb = durString[0].match(/\d+/g)
|
|
106
123
|
|
|
107
124
|
if (durNumb) {
|
|
108
|
-
duration = parseInt(durNumb[0])
|
|
125
|
+
duration = parseInt(durNumb[0])
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
}
|
|
112
129
|
} else {
|
|
113
130
|
switch (info) {
|
|
114
131
|
case 'EXT-X-CUE-OUT':
|
|
115
|
-
kind = OUT
|
|
116
|
-
break
|
|
132
|
+
kind = OUT
|
|
133
|
+
break
|
|
117
134
|
case 'EXT-X-CUE-OUT-CONT':
|
|
118
|
-
kind = OUT_CONT
|
|
119
|
-
break
|
|
135
|
+
kind = OUT_CONT
|
|
136
|
+
break
|
|
120
137
|
case 'EXT-X-CUE-IN':
|
|
121
|
-
kind = IN
|
|
122
|
-
break
|
|
138
|
+
kind = IN
|
|
139
|
+
break
|
|
123
140
|
}
|
|
124
141
|
}
|
|
125
|
-
})
|
|
126
|
-
kind &&
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
})
|
|
143
|
+
kind &&
|
|
144
|
+
(cueResult = {
|
|
145
|
+
kind,
|
|
146
|
+
duration,
|
|
147
|
+
})
|
|
130
148
|
}
|
|
131
149
|
|
|
132
|
-
return cueResult
|
|
150
|
+
return cueResult
|
|
133
151
|
}
|
|
134
152
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
export type AdRollType =
|
|
1
|
+
export type AdRollType =
|
|
2
|
+
| 'preroll'
|
|
3
|
+
| 'middleroll'
|
|
4
|
+
| 'repeatableroll'
|
|
5
|
+
| 'pauseroll'
|
|
6
|
+
| 'postroll'
|
|
7
|
+
| 'scteroll'
|
|
2
8
|
|
|
3
9
|
export type AdRollItem = {
|
|
4
|
-
startTime: number
|
|
5
|
-
startTimePercent: number
|
|
6
|
-
tag: string
|
|
7
|
-
}
|
|
10
|
+
startTime: number
|
|
11
|
+
startTimePercent: number
|
|
12
|
+
tag: string
|
|
13
|
+
}
|
|
8
14
|
|
|
9
15
|
export type AdRollDesc = {
|
|
10
|
-
data: AdRollItem[]
|
|
11
|
-
oneByOne?: boolean
|
|
12
|
-
}
|
|
16
|
+
data: AdRollItem[]
|
|
17
|
+
oneByOne?: boolean
|
|
18
|
+
}
|
|
13
19
|
|
|
14
|
-
export type VastAdsOptions = Partial<Record<AdRollType, AdRollDesc
|
|
20
|
+
export type VastAdsOptions = Partial<Record<AdRollType, AdRollDesc>>
|
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
import XHRURLHandler from './xmlhttprequest.js'
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import XHRURLHandler from './xmlhttprequest.js'
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
5
|
-
const ERROR_MESSAGE =
|
|
5
|
+
const ERROR_MESSAGE =
|
|
6
|
+
'Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler'
|
|
6
7
|
|
|
7
8
|
export default class URLHandler {
|
|
8
|
-
static get(
|
|
9
|
+
static get(
|
|
10
|
+
url: string,
|
|
11
|
+
options: any,
|
|
12
|
+
cb?: (err: any | null, response?: any) => void,
|
|
13
|
+
) {
|
|
9
14
|
// Allow skip of the options param
|
|
10
15
|
if (!cb) {
|
|
11
16
|
if (typeof options === 'function') {
|
|
12
|
-
cb = options
|
|
17
|
+
cb = options
|
|
13
18
|
}
|
|
14
|
-
options = {}
|
|
19
|
+
options = {}
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
assert(cb, 'URLHandler.get: callback is required')
|
|
22
|
+
assert(cb, 'URLHandler.get: callback is required')
|
|
18
23
|
if (options.response) {
|
|
19
24
|
// Trick: the VAST response XML document is passed as an option
|
|
20
|
-
const { response } = options
|
|
25
|
+
const { response } = options
|
|
21
26
|
|
|
22
|
-
delete options.response
|
|
27
|
+
delete options.response
|
|
23
28
|
|
|
24
|
-
return cb(null, response)
|
|
29
|
+
return cb(null, response)
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
if (options.urlhandler?.supported()) {
|
|
28
33
|
// explicitly supply your own URLHandler object
|
|
29
|
-
return options.urlhandler.get(url, options, cb)
|
|
34
|
+
return options.urlhandler.get(url, options, cb)
|
|
30
35
|
}
|
|
31
36
|
if (XHRURLHandler.supported()) {
|
|
32
|
-
return XHRURLHandler.get(url, options, cb)
|
|
37
|
+
return XHRURLHandler.get(url, options, cb)
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
return cb(new Error(ERROR_MESSAGE))
|
|
40
|
+
return cb(new Error(ERROR_MESSAGE))
|
|
36
41
|
}
|
|
37
42
|
}
|
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
import { reportError } from '@gcorevideo/utils'
|
|
2
|
-
import assert from
|
|
1
|
+
import { reportError } from '@gcorevideo/utils'
|
|
2
|
+
import assert from 'assert'
|
|
3
3
|
|
|
4
4
|
export default class XHRURLHandler {
|
|
5
5
|
static xhrCreate(): XMLHttpRequest | false {
|
|
6
|
-
const xhr = new window.XMLHttpRequest()
|
|
6
|
+
const xhr = new window.XMLHttpRequest()
|
|
7
7
|
|
|
8
|
-
if ('withCredentials' in xhr) {
|
|
9
|
-
|
|
8
|
+
if ('withCredentials' in xhr) {
|
|
9
|
+
// check CORS support
|
|
10
|
+
return xhr
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
return false
|
|
13
|
+
return false
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
static supported() {
|
|
16
|
-
return !!this.xhrCreate()
|
|
17
|
+
return !!this.xhrCreate()
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
static get(
|
|
20
|
+
static get(
|
|
21
|
+
url: string,
|
|
22
|
+
options: any,
|
|
23
|
+
cb: (err: Error | null, response?: any) => void,
|
|
24
|
+
) {
|
|
20
25
|
try {
|
|
21
|
-
const xhr = this.xhrCreate()
|
|
22
|
-
assert(xhr, 'XHRURLHandler: XMLHttpRequest is not supported')
|
|
26
|
+
const xhr = this.xhrCreate()
|
|
27
|
+
assert(xhr, 'XHRURLHandler: XMLHttpRequest is not supported')
|
|
23
28
|
|
|
24
|
-
xhr.open('GET', url)
|
|
25
|
-
xhr.timeout = options.timeout || 0
|
|
26
|
-
xhr.withCredentials = options.withCredentials || false
|
|
27
|
-
xhr.onreadystatechange = function() {
|
|
29
|
+
xhr.open('GET', url)
|
|
30
|
+
xhr.timeout = options.timeout || 0
|
|
31
|
+
xhr.withCredentials = options.withCredentials || false
|
|
32
|
+
xhr.onreadystatechange = function () {
|
|
28
33
|
if (xhr.readyState === 4) {
|
|
29
34
|
if (xhr.status === 200) {
|
|
30
|
-
return cb(null, xhr.response)
|
|
35
|
+
return cb(null, xhr.response)
|
|
31
36
|
} else {
|
|
32
|
-
return cb(new Error(`XHRURLHandler: ${xhr.statusText}`))
|
|
37
|
+
return cb(new Error(`XHRURLHandler: ${xhr.statusText}`))
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
}
|
|
40
|
+
}
|
|
36
41
|
|
|
37
|
-
return xhr.send()
|
|
42
|
+
return xhr.send()
|
|
38
43
|
} catch (error) {
|
|
39
44
|
// LogManager.exception(error);
|
|
40
|
-
reportError(error)
|
|
41
|
-
return cb(new Error('XHRURLHandler: Unexpected error'))
|
|
45
|
+
reportError(error)
|
|
46
|
+
return cb(new Error('XHRURLHandler: Unexpected error'))
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
}
|
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import { reportError } from '@gcorevideo/utils'
|
|
2
|
-
import assert from
|
|
1
|
+
import { reportError } from '@gcorevideo/utils'
|
|
2
|
+
import assert from 'assert'
|
|
3
3
|
|
|
4
4
|
export default class MergeVast {
|
|
5
|
-
private firstXML: Document
|
|
6
|
-
private secondXML: Document
|
|
5
|
+
private firstXML: Document
|
|
6
|
+
private secondXML: Document
|
|
7
7
|
|
|
8
|
-
private firstVAST: HTMLCollectionOf<Element
|
|
9
|
-
private secondVAST: HTMLCollectionOf<Element
|
|
8
|
+
private firstVAST: HTMLCollectionOf<Element>
|
|
9
|
+
private secondVAST: HTMLCollectionOf<Element>
|
|
10
10
|
|
|
11
11
|
constructor(xml1: string, xml2: string) {
|
|
12
|
-
this.firstXML = this._stringToXML(xml1)
|
|
13
|
-
this.secondXML = this._stringToXML(xml2)
|
|
14
|
-
this.firstVAST = this.firstXML.getElementsByTagName('VAST')
|
|
15
|
-
this.secondVAST = this.secondXML.getElementsByTagName('VAST')
|
|
12
|
+
this.firstXML = this._stringToXML(xml1)
|
|
13
|
+
this.secondXML = this._stringToXML(xml2)
|
|
14
|
+
this.firstVAST = this.firstXML.getElementsByTagName('VAST')
|
|
15
|
+
this.secondVAST = this.secondXML.getElementsByTagName('VAST')
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
merge() {
|
|
19
|
-
const res = this._mergeXML(this.firstVAST, this.secondVAST)
|
|
19
|
+
const res = this._mergeXML(this.firstVAST, this.secondVAST)
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
return res[0].outerHTML
|
|
22
|
+
return res[0].outerHTML
|
|
23
23
|
} catch (error) {
|
|
24
24
|
// LogManager.exception(error);
|
|
25
|
-
reportError(error)
|
|
25
|
+
reportError(error)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
return ''
|
|
28
|
+
return ''
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
_mergeXML(
|
|
31
|
+
_mergeXML(
|
|
32
|
+
first: HTMLCollectionOf<Element>,
|
|
33
|
+
second: HTMLCollectionOf<Element>,
|
|
34
|
+
parent?: Element,
|
|
35
|
+
): HTMLCollectionOf<Element> {
|
|
32
36
|
// const sources = [].slice.call( arguments, 0 );
|
|
33
37
|
// const first = sources[0];
|
|
34
38
|
// const second = sources[1];
|
|
35
39
|
// const parent = sources[2];
|
|
36
40
|
|
|
37
41
|
for (let i = 0; i < first.length; i++) {
|
|
38
|
-
let secondItems = this._getPieceTree(first[i].nodeName,second)
|
|
42
|
+
let secondItems = this._getPieceTree(first[i].nodeName, second)
|
|
39
43
|
|
|
40
44
|
if (
|
|
41
45
|
first[i].nodeName === 'Tracking' ||
|
|
@@ -45,52 +49,58 @@ export default class MergeVast {
|
|
|
45
49
|
first[i].nodeName === 'ClickTracking' ||
|
|
46
50
|
first[i].nodeName === 'ClickThrough'
|
|
47
51
|
) {
|
|
48
|
-
secondItems = null
|
|
52
|
+
secondItems = null
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
if (!secondItems) {
|
|
52
56
|
try {
|
|
53
|
-
assert(parent, 'parent is null')
|
|
54
|
-
parent.appendChild(first[i].cloneNode(true))
|
|
57
|
+
assert(parent, 'parent is null')
|
|
58
|
+
parent.appendChild(first[i].cloneNode(true))
|
|
55
59
|
} catch (error) {
|
|
56
60
|
// LogManager.exception(error);
|
|
57
|
-
reportError(error)
|
|
61
|
+
reportError(error)
|
|
58
62
|
}
|
|
59
63
|
} else {
|
|
60
64
|
if (first[i].children.length > 0 && secondItems) {
|
|
61
|
-
this._mergeXML(first[i].children, secondItems.children, secondItems
|
|
65
|
+
this._mergeXML(first[i].children, secondItems.children, secondItems)
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
return second
|
|
70
|
+
return second
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
_getPieceTree(
|
|
73
|
+
_getPieceTree(
|
|
74
|
+
nodeName: string,
|
|
75
|
+
xml: HTMLCollectionOf<Element>,
|
|
76
|
+
): Element | null {
|
|
70
77
|
if (xml) {
|
|
71
78
|
if (xml instanceof HTMLCollection) {
|
|
72
79
|
for (const item of xml) {
|
|
73
80
|
if (item.nodeName === nodeName) {
|
|
74
|
-
return item
|
|
81
|
+
return item
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
return null
|
|
87
|
+
return null
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
_stringToXML(val: string): Document {
|
|
84
|
-
let xmlDoc = null
|
|
91
|
+
let xmlDoc = null
|
|
85
92
|
|
|
86
|
-
if (
|
|
87
|
-
|
|
93
|
+
if (
|
|
94
|
+
document.implementation &&
|
|
95
|
+
(document.implementation as any).createDocument
|
|
96
|
+
) {
|
|
97
|
+
return new DOMParser().parseFromString(val, 'application/xml')
|
|
88
98
|
} else if ('ActiveXObject' in window) {
|
|
89
|
-
xmlDoc = new (window.ActiveXObject as any)('Microsoft.XMLDOM')
|
|
90
|
-
xmlDoc.loadXML(val)
|
|
91
|
-
return xmlDoc
|
|
99
|
+
xmlDoc = new (window.ActiveXObject as any)('Microsoft.XMLDOM')
|
|
100
|
+
xmlDoc.loadXML(val)
|
|
101
|
+
return xmlDoc
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
throw new Error('XML Parser not found')
|
|
104
|
+
throw new Error('XML Parser not found')
|
|
95
105
|
}
|
|
96
106
|
}
|
|
@@ -1,104 +1,112 @@
|
|
|
1
|
-
import { Matrix4 } from 'three'
|
|
2
|
-
import LogManager from '../../utils/LogManager'
|
|
3
|
-
import { SentryLogLevel } from '../../constants'
|
|
1
|
+
import { Matrix4 } from 'three'
|
|
2
|
+
import LogManager from '../../utils/LogManager'
|
|
3
|
+
import { SentryLogLevel } from '../../constants'
|
|
4
4
|
|
|
5
5
|
export class VRControls {
|
|
6
6
|
constructor(object, onError) {
|
|
7
|
-
const scope = this
|
|
8
|
-
let vrDisplay, vrDisplays
|
|
9
|
-
const standingMatrix = new Matrix4()
|
|
10
|
-
let frameData = null
|
|
7
|
+
const scope = this
|
|
8
|
+
let vrDisplay, vrDisplays
|
|
9
|
+
const standingMatrix = new Matrix4()
|
|
10
|
+
let frameData = null
|
|
11
11
|
|
|
12
12
|
if ('VRFrameData' in window) {
|
|
13
|
-
frameData = new VRFrameData()
|
|
13
|
+
frameData = new VRFrameData()
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function gotVRDisplays(displays) {
|
|
17
|
-
vrDisplays = displays
|
|
17
|
+
vrDisplays = displays
|
|
18
18
|
if (displays.length > 0) {
|
|
19
|
-
vrDisplay = displays[0]
|
|
19
|
+
vrDisplay = displays[0]
|
|
20
20
|
} else {
|
|
21
21
|
if (onError) {
|
|
22
|
-
onError('VR input not available.')
|
|
22
|
+
onError('VR input not available.')
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (navigator.getVRDisplays) {
|
|
28
|
-
navigator
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
navigator
|
|
29
|
+
.getVRDisplays()
|
|
30
|
+
.then(gotVRDisplays)
|
|
31
|
+
.catch(function () {
|
|
32
|
+
LogManager.message(
|
|
33
|
+
'THREE.VRControls: Unable to get VR Displays',
|
|
34
|
+
SentryLogLevel.WARNING,
|
|
35
|
+
)
|
|
36
|
+
console.warn('THREE.VRControls: Unable to get VR Displays')
|
|
37
|
+
})
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
// the Rift SDK returns the position in meters
|
|
35
41
|
// this scale factor allows the user to define how meters
|
|
36
42
|
// are converted to scene units.
|
|
37
43
|
|
|
38
|
-
this.scale = 1
|
|
44
|
+
this.scale = 1
|
|
39
45
|
|
|
40
46
|
// If true will use "standing space" coordinate system where y=0 is the
|
|
41
47
|
// floor and x=0, z=0 is the center of the room.
|
|
42
|
-
this.standing = false
|
|
48
|
+
this.standing = false
|
|
43
49
|
|
|
44
50
|
// Distance from the users eyes to the floor in meters. Used when
|
|
45
51
|
// standing=true but the VRDisplay doesn't provide stageParameters.
|
|
46
|
-
this.userHeight = 1.6
|
|
52
|
+
this.userHeight = 1.6
|
|
47
53
|
|
|
48
54
|
this.getVRDisplay = function () {
|
|
49
|
-
return vrDisplay
|
|
50
|
-
}
|
|
55
|
+
return vrDisplay
|
|
56
|
+
}
|
|
51
57
|
|
|
52
58
|
this.setVRDisplay = function (value) {
|
|
53
|
-
vrDisplay = value
|
|
54
|
-
}
|
|
59
|
+
vrDisplay = value
|
|
60
|
+
}
|
|
55
61
|
|
|
56
62
|
this.getVRDisplays = function () {
|
|
57
|
-
console.warn('THREE.VRControls: getVRDisplays() is being deprecated.')
|
|
63
|
+
console.warn('THREE.VRControls: getVRDisplays() is being deprecated.')
|
|
58
64
|
|
|
59
|
-
return vrDisplays
|
|
60
|
-
}
|
|
65
|
+
return vrDisplays
|
|
66
|
+
}
|
|
61
67
|
|
|
62
68
|
this.getStandingMatrix = function () {
|
|
63
|
-
return standingMatrix
|
|
64
|
-
}
|
|
69
|
+
return standingMatrix
|
|
70
|
+
}
|
|
65
71
|
|
|
66
72
|
this.update = function () {
|
|
67
73
|
if (vrDisplay) {
|
|
68
|
-
let pose
|
|
74
|
+
let pose
|
|
69
75
|
|
|
70
76
|
if (vrDisplay.getFrameData) {
|
|
71
|
-
vrDisplay.getFrameData(frameData)
|
|
72
|
-
pose = frameData.pose
|
|
77
|
+
vrDisplay.getFrameData(frameData)
|
|
78
|
+
pose = frameData.pose
|
|
73
79
|
} else if (vrDisplay.getPose) {
|
|
74
|
-
pose = vrDisplay.getPose()
|
|
80
|
+
pose = vrDisplay.getPose()
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
if (pose.orientation) {
|
|
78
|
-
object.quaternion.fromArray(pose.orientation)
|
|
84
|
+
object.quaternion.fromArray(pose.orientation)
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
if (pose.position) {
|
|
82
|
-
object.position.fromArray(pose.position)
|
|
88
|
+
object.position.fromArray(pose.position)
|
|
83
89
|
} else {
|
|
84
|
-
object.position.set(0, 0, 0)
|
|
90
|
+
object.position.set(0, 0, 0)
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
if (this.standing) {
|
|
88
94
|
if (vrDisplay.stageParameters) {
|
|
89
|
-
object.updateMatrix()
|
|
90
|
-
standingMatrix.fromArray(
|
|
91
|
-
|
|
95
|
+
object.updateMatrix()
|
|
96
|
+
standingMatrix.fromArray(
|
|
97
|
+
vrDisplay.stageParameters.sittingToStandingTransform,
|
|
98
|
+
)
|
|
99
|
+
object.applyMatrix(standingMatrix)
|
|
92
100
|
} else {
|
|
93
|
-
object.position.setY(object.position.y + this.userHeight)
|
|
101
|
+
object.position.setY(object.position.y + this.userHeight)
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
|
-
object.position.multiplyScalar(scope.scale)
|
|
104
|
+
object.position.multiplyScalar(scope.scale)
|
|
97
105
|
}
|
|
98
|
-
}
|
|
106
|
+
}
|
|
99
107
|
|
|
100
108
|
this.dispose = function () {
|
|
101
|
-
vrDisplay = null
|
|
102
|
-
}
|
|
109
|
+
vrDisplay = null
|
|
110
|
+
}
|
|
103
111
|
}
|
|
104
112
|
}
|