@gcorevideo/player 2.28.25 → 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 +38 -32
- package/dist/index.css +223 -223
- package/dist/index.embed.js +95 -38
- package/dist/index.js +227 -122
- 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 +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/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
|
@@ -27,7 +27,11 @@ export function parseClips(text: string): ClipDesc[] {
|
|
|
27
27
|
}))
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function buildSvg(
|
|
30
|
+
export function buildSvg(
|
|
31
|
+
clips: ClipDesc[],
|
|
32
|
+
duration: number,
|
|
33
|
+
barWidth: number,
|
|
34
|
+
): string {
|
|
31
35
|
let svg =
|
|
32
36
|
'<svg width="0" height="0">\n' + '<defs>\n' + '<clipPath id="myClip">\n'
|
|
33
37
|
let rightEdge = 0
|
|
@@ -152,7 +152,7 @@ export class CmcdConfig extends CorePlugin {
|
|
|
152
152
|
private generateContentId() {
|
|
153
153
|
const src =
|
|
154
154
|
this.core.options.source ??
|
|
155
|
-
(typeof this.core.options.sources[0]
|
|
155
|
+
(typeof this.core.options.sources[0] === 'string'
|
|
156
156
|
? this.core.options.sources[0]
|
|
157
157
|
: this.core.options.sources[0].source)
|
|
158
158
|
return new URL(src).pathname.slice(0, 64)
|
|
@@ -18,11 +18,11 @@ describe('ErrorScreen', () => {
|
|
|
18
18
|
[
|
|
19
19
|
'targeted at UI',
|
|
20
20
|
{
|
|
21
|
-
code:
|
|
21
|
+
code: 'foo',
|
|
22
22
|
UI: {
|
|
23
23
|
title: 'My error',
|
|
24
24
|
message: 'Lorem ipsum dolor sit amet',
|
|
25
|
-
icon: '<svg>...</svg>'
|
|
25
|
+
icon: '<svg>...</svg>',
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
true,
|
|
@@ -36,7 +36,7 @@ describe('ErrorScreen', () => {
|
|
|
36
36
|
},
|
|
37
37
|
false,
|
|
38
38
|
],
|
|
39
|
-
])(
|
|
39
|
+
])('%s', (_, err, shouldRender) => {
|
|
40
40
|
beforeEach(() => {
|
|
41
41
|
errorScreen = new ErrorScreen(core)
|
|
42
42
|
core.emit('core:ready')
|
|
@@ -66,28 +66,34 @@ describe('ErrorScreen', () => {
|
|
|
66
66
|
UI: {
|
|
67
67
|
title: 'My error',
|
|
68
68
|
message: 'Lorem ipsum dolor sit amet',
|
|
69
|
-
icon: '<svg>...</svg>'
|
|
69
|
+
icon: '<svg>...</svg>',
|
|
70
70
|
},
|
|
71
71
|
})
|
|
72
72
|
core.configure.mockClear()
|
|
73
73
|
})
|
|
74
74
|
describe('when clicked', () => {
|
|
75
75
|
beforeEach(async () => {
|
|
76
|
-
(
|
|
77
|
-
|
|
76
|
+
;(
|
|
77
|
+
errorScreen.el.querySelector(
|
|
78
|
+
'.player-error-screen__reload',
|
|
79
|
+
) as HTMLElement
|
|
80
|
+
)?.click()
|
|
81
|
+
return new Promise((resolve) => setTimeout(resolve, 0))
|
|
78
82
|
})
|
|
79
83
|
it('should reload the player', () => {
|
|
80
|
-
expect(core.configure).toHaveBeenCalledWith(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
expect(core.configure).toHaveBeenCalledWith(
|
|
85
|
+
expect.objectContaining({
|
|
86
|
+
reloading: true,
|
|
87
|
+
source: 'https://222/master.mpd',
|
|
88
|
+
}),
|
|
89
|
+
)
|
|
84
90
|
})
|
|
85
91
|
})
|
|
86
92
|
})
|
|
87
93
|
describe('when disabled', () => {
|
|
88
94
|
beforeEach(() => {
|
|
89
95
|
core.options.errorScreen = {
|
|
90
|
-
noReload: true
|
|
96
|
+
noReload: true,
|
|
91
97
|
}
|
|
92
98
|
errorScreen = new ErrorScreen(core)
|
|
93
99
|
core.emit('core:ready')
|
|
@@ -97,16 +103,16 @@ describe('ErrorScreen', () => {
|
|
|
97
103
|
UI: {
|
|
98
104
|
title: 'My error',
|
|
99
105
|
message: 'Lorem ipsum dolor sit amet',
|
|
100
|
-
icon: '<svg>...</svg>'
|
|
106
|
+
icon: '<svg>...</svg>',
|
|
101
107
|
},
|
|
102
108
|
})
|
|
103
109
|
})
|
|
104
110
|
it('should not render the reload button', () => {
|
|
105
|
-
expect(
|
|
111
|
+
expect(
|
|
112
|
+
errorScreen.el.querySelector('.player-error-screen__reload'),
|
|
113
|
+
).toBeNull()
|
|
106
114
|
})
|
|
107
115
|
})
|
|
108
116
|
})
|
|
109
117
|
})
|
|
110
118
|
})
|
|
111
|
-
|
|
112
|
-
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CorePlugin, Events, $, Core, Container } from '@clappr/core'
|
|
1
|
+
import { CorePlugin, Events, $, Core, Container } from '@clappr/core'
|
|
2
2
|
|
|
3
|
-
import { CLAPPR_VERSION } from '../../build.js'
|
|
4
|
-
import { ZeptoResult } from '../../types.js'
|
|
3
|
+
import { CLAPPR_VERSION } from '../../build.js'
|
|
4
|
+
import { ZeptoResult } from '../../types.js'
|
|
5
5
|
|
|
6
|
-
import playIcon from '../../../assets/icons/new/play.svg'
|
|
7
|
-
import pauseIcon from '../../../assets/icons/new/pause.svg'
|
|
8
|
-
import stopIcon from '../../../assets/icons/new/stop.svg'
|
|
6
|
+
import playIcon from '../../../assets/icons/new/play.svg'
|
|
7
|
+
import pauseIcon from '../../../assets/icons/new/pause.svg'
|
|
8
|
+
import stopIcon from '../../../assets/icons/new/stop.svg'
|
|
9
9
|
|
|
10
|
-
const FAVICON_COLOR = '#567'
|
|
11
|
-
const FAVICON_SELECTOR = 'link[rel="shortcut icon"]'
|
|
10
|
+
const FAVICON_COLOR = '#567'
|
|
11
|
+
const FAVICON_SELECTOR = 'link[rel="shortcut icon"]'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @public
|
|
@@ -17,7 +17,7 @@ export interface FaviconPluginSettings {
|
|
|
17
17
|
/**
|
|
18
18
|
* CSS color of the favicon.
|
|
19
19
|
*/
|
|
20
|
-
faviconColor?: string
|
|
20
|
+
faviconColor?: string
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -27,37 +27,37 @@ export interface FaviconPluginSettings {
|
|
|
27
27
|
* There are three states: stopped, playing and paused.
|
|
28
28
|
*/
|
|
29
29
|
export class Favicon extends CorePlugin {
|
|
30
|
-
private oldIcon: ZeptoResult
|
|
30
|
+
private oldIcon: ZeptoResult
|
|
31
31
|
|
|
32
|
-
private playIcon: ZeptoResult | null = null
|
|
32
|
+
private playIcon: ZeptoResult | null = null
|
|
33
33
|
|
|
34
|
-
private pauseIcon: ZeptoResult | null = null
|
|
34
|
+
private pauseIcon: ZeptoResult | null = null
|
|
35
35
|
|
|
36
|
-
private stopIcon: ZeptoResult | null = null
|
|
36
|
+
private stopIcon: ZeptoResult | null = null
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
41
41
|
get name() {
|
|
42
|
-
return 'favicon'
|
|
42
|
+
return 'favicon'
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* @internal
|
|
47
47
|
*/
|
|
48
48
|
get supportedVersion() {
|
|
49
|
-
return { min: CLAPPR_VERSION }
|
|
49
|
+
return { min: CLAPPR_VERSION }
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
55
55
|
constructor(core: Core) {
|
|
56
|
-
super(core)
|
|
57
|
-
this.oldIcon = $(FAVICON_SELECTOR)
|
|
56
|
+
super(core)
|
|
57
|
+
this.oldIcon = $(FAVICON_SELECTOR)
|
|
58
58
|
if (this.oldIcon.length === 0) {
|
|
59
|
-
this.stopIcon = this.createIcon(stopIcon)
|
|
60
|
-
this.changeIcon(this.stopIcon)
|
|
59
|
+
this.stopIcon = this.createIcon(stopIcon)
|
|
60
|
+
this.changeIcon(this.stopIcon)
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -65,74 +65,98 @@ export class Favicon extends CorePlugin {
|
|
|
65
65
|
* @internal
|
|
66
66
|
*/
|
|
67
67
|
override bindEvents() {
|
|
68
|
-
this.listenTo(
|
|
68
|
+
this.listenTo(
|
|
69
|
+
this.core,
|
|
70
|
+
Events.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
71
|
+
this.containerChanged,
|
|
72
|
+
)
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
private containerChanged() {
|
|
72
|
-
this.listenTo(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
76
|
+
this.listenTo(
|
|
77
|
+
this.core.activeContainer,
|
|
78
|
+
Events.CONTAINER_PLAY,
|
|
79
|
+
this.setPlayIcon,
|
|
80
|
+
)
|
|
81
|
+
this.listenTo(
|
|
82
|
+
this.core.activeContainer,
|
|
83
|
+
Events.CONTAINER_PAUSE,
|
|
84
|
+
this.setPauseIcon,
|
|
85
|
+
)
|
|
86
|
+
this.listenTo(
|
|
87
|
+
this.core.activeContainer,
|
|
88
|
+
Events.CONTAINER_STOP,
|
|
89
|
+
this.resetIcon,
|
|
90
|
+
)
|
|
91
|
+
this.listenTo(
|
|
92
|
+
this.core.activeContainer,
|
|
93
|
+
Events.CONTAINER_ENDED,
|
|
94
|
+
this.resetIcon,
|
|
95
|
+
)
|
|
96
|
+
this.listenTo(
|
|
97
|
+
this.core.activeContainer,
|
|
98
|
+
Events.CONTAINER_ERROR,
|
|
99
|
+
this.resetIcon,
|
|
100
|
+
)
|
|
101
|
+
this.resetIcon()
|
|
78
102
|
}
|
|
79
103
|
|
|
80
104
|
/**
|
|
81
105
|
* @internal
|
|
82
106
|
*/
|
|
83
107
|
override disable() {
|
|
84
|
-
super.disable()
|
|
85
|
-
this.resetIcon()
|
|
108
|
+
super.disable()
|
|
109
|
+
this.resetIcon()
|
|
86
110
|
}
|
|
87
111
|
|
|
88
112
|
/**
|
|
89
113
|
* @internal
|
|
90
114
|
*/
|
|
91
115
|
override destroy() {
|
|
92
|
-
super.destroy()
|
|
93
|
-
this.resetIcon()
|
|
116
|
+
super.destroy()
|
|
117
|
+
this.resetIcon()
|
|
94
118
|
}
|
|
95
119
|
|
|
96
120
|
private createIcon(svg: string) {
|
|
97
|
-
const canvas = $('<canvas/>')
|
|
121
|
+
const canvas = $('<canvas/>')
|
|
98
122
|
|
|
99
|
-
canvas[0].width = 24
|
|
100
|
-
canvas[0].height = 24
|
|
101
|
-
const ctx = canvas[0].getContext('2d')
|
|
123
|
+
canvas[0].width = 24
|
|
124
|
+
canvas[0].height = 24
|
|
125
|
+
const ctx = canvas[0].getContext('2d')
|
|
102
126
|
|
|
103
|
-
ctx.fillStyle = this.core.options.faviconColor || FAVICON_COLOR
|
|
104
|
-
const d = $(svg).find('path').attr('d')
|
|
105
|
-
const path = new Path2D(d)
|
|
127
|
+
ctx.fillStyle = this.core.options.faviconColor || FAVICON_COLOR
|
|
128
|
+
const d = $(svg).find('path').attr('d')
|
|
129
|
+
const path = new Path2D(d)
|
|
106
130
|
|
|
107
|
-
ctx.fill(path)
|
|
108
|
-
const icon = $('<link rel="shortcut icon" type="image/png"/>')
|
|
131
|
+
ctx.fill(path)
|
|
132
|
+
const icon = $('<link rel="shortcut icon" type="image/png"/>')
|
|
109
133
|
|
|
110
|
-
icon.attr('href', canvas[0].toDataURL('image/png'))
|
|
134
|
+
icon.attr('href', canvas[0].toDataURL('image/png'))
|
|
111
135
|
|
|
112
|
-
return icon
|
|
136
|
+
return icon
|
|
113
137
|
}
|
|
114
138
|
|
|
115
139
|
private setPlayIcon() {
|
|
116
140
|
if (!this.playIcon) {
|
|
117
|
-
this.playIcon = this.createIcon(playIcon)
|
|
141
|
+
this.playIcon = this.createIcon(playIcon)
|
|
118
142
|
}
|
|
119
|
-
this.changeIcon(this.playIcon)
|
|
143
|
+
this.changeIcon(this.playIcon)
|
|
120
144
|
}
|
|
121
145
|
|
|
122
146
|
private setPauseIcon() {
|
|
123
147
|
if (!this.pauseIcon) {
|
|
124
|
-
this.pauseIcon = this.createIcon(pauseIcon)
|
|
148
|
+
this.pauseIcon = this.createIcon(pauseIcon)
|
|
125
149
|
}
|
|
126
|
-
this.changeIcon(this.pauseIcon)
|
|
150
|
+
this.changeIcon(this.pauseIcon)
|
|
127
151
|
}
|
|
128
152
|
|
|
129
153
|
private resetIcon() {
|
|
130
|
-
const icon = this.oldIcon.length > 0 ? this.oldIcon : this.stopIcon
|
|
131
|
-
this.changeIcon(icon)
|
|
154
|
+
const icon = this.oldIcon.length > 0 ? this.oldIcon : this.stopIcon
|
|
155
|
+
this.changeIcon(icon)
|
|
132
156
|
}
|
|
133
157
|
|
|
134
158
|
private changeIcon(icon: ZeptoResult) {
|
|
135
|
-
$('link[rel="shortcut icon"]').remove()
|
|
136
|
-
$('head').append(icon)
|
|
159
|
+
$('link[rel="shortcut icon"]').remove()
|
|
160
|
+
$('head').append(icon)
|
|
137
161
|
}
|
|
138
162
|
}
|
|
@@ -2,150 +2,185 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style
|
|
3
3
|
// license that can be found at https://github.com/clappr/clappr-plugins/blob/master/LICENSE
|
|
4
4
|
|
|
5
|
-
import { Container, ContainerPlugin, Events } from '@clappr/core'
|
|
5
|
+
import { Container, ContainerPlugin, Events } from '@clappr/core'
|
|
6
6
|
|
|
7
|
-
import { CLAPPR_VERSION } from '../../build.js'
|
|
7
|
+
import { CLAPPR_VERSION } from '../../build.js'
|
|
8
8
|
|
|
9
9
|
declare const _gaq: {
|
|
10
|
-
push(args: string[]): void
|
|
11
|
-
}
|
|
10
|
+
push(args: string[]): void
|
|
11
|
+
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* `PLUGIN` that integrates with Google Analytics
|
|
15
15
|
* @beta
|
|
16
16
|
*/
|
|
17
17
|
export class GoogleAnalytics extends ContainerPlugin {
|
|
18
|
-
private account: string = ''
|
|
18
|
+
private account: string = ''
|
|
19
19
|
|
|
20
|
-
private trackerName: string = ''
|
|
20
|
+
private trackerName: string = ''
|
|
21
21
|
|
|
22
|
-
private domainName: string = ''
|
|
22
|
+
private domainName: string = ''
|
|
23
23
|
|
|
24
24
|
private currentHDState: string | undefined
|
|
25
25
|
|
|
26
26
|
get name() {
|
|
27
|
-
return 'google_analytics'
|
|
27
|
+
return 'google_analytics'
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
get supportedVersion() {
|
|
31
|
-
return { min: CLAPPR_VERSION }
|
|
31
|
+
return { min: CLAPPR_VERSION }
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
constructor(container: Container) {
|
|
35
|
-
super(container)
|
|
35
|
+
super(container)
|
|
36
36
|
if (this.container.options.gaAccount) {
|
|
37
|
-
this.account = this.container.options.gaAccount
|
|
38
|
-
this.trackerName =
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
this.account = this.container.options.gaAccount
|
|
38
|
+
this.trackerName = this.container.options.gaTrackerName
|
|
39
|
+
? this.container.options.gaTrackerName + '.'
|
|
40
|
+
: 'Player.'
|
|
41
|
+
this.domainName = this.container.options.gaDomainName
|
|
42
|
+
this.embedScript()
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
embedScript() {
|
|
45
|
-
if (!('_gat' in window)) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
script.setAttribute('
|
|
50
|
-
script.setAttribute('
|
|
51
|
-
script.
|
|
52
|
-
|
|
47
|
+
if (!('_gat' in window)) {
|
|
48
|
+
// TODO
|
|
49
|
+
const script = document.createElement('script')
|
|
50
|
+
|
|
51
|
+
script.setAttribute('type', 'text/javascript')
|
|
52
|
+
script.setAttribute('async', 'async')
|
|
53
|
+
script.setAttribute('src', '//www.google-analytics.com/ga.js')
|
|
54
|
+
script.onload = () => this.addEventListeners()
|
|
55
|
+
document.body.appendChild(script)
|
|
53
56
|
} else {
|
|
54
|
-
this.addEventListeners()
|
|
57
|
+
this.addEventListeners()
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
addEventListeners() {
|
|
59
62
|
if (this.container) {
|
|
60
|
-
this.listenTo(this.container, Events.CONTAINER_READY, this.onReady)
|
|
61
|
-
this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay)
|
|
62
|
-
this.listenTo(this.container, Events.CONTAINER_STOP, this.onStop)
|
|
63
|
-
this.listenTo(this.container, Events.CONTAINER_PAUSE, this.onPause)
|
|
64
|
-
this.listenTo(this.container, Events.CONTAINER_ENDED, this.onEnded)
|
|
65
|
-
this.listenTo(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.listenTo(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
this.listenTo(this.container, Events.CONTAINER_READY, this.onReady)
|
|
64
|
+
this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay)
|
|
65
|
+
this.listenTo(this.container, Events.CONTAINER_STOP, this.onStop)
|
|
66
|
+
this.listenTo(this.container, Events.CONTAINER_PAUSE, this.onPause)
|
|
67
|
+
this.listenTo(this.container, Events.CONTAINER_ENDED, this.onEnded)
|
|
68
|
+
this.listenTo(
|
|
69
|
+
this.container,
|
|
70
|
+
Events.CONTAINER_STATE_BUFFERING,
|
|
71
|
+
this.onBuffering,
|
|
72
|
+
)
|
|
73
|
+
this.listenTo(
|
|
74
|
+
this.container,
|
|
75
|
+
Events.CONTAINER_STATE_BUFFERFULL,
|
|
76
|
+
this.onBufferFull,
|
|
77
|
+
)
|
|
78
|
+
this.listenTo(this.container, Events.CONTAINER_ERROR, this.onError)
|
|
79
|
+
this.listenTo(
|
|
80
|
+
this.container,
|
|
81
|
+
Events.CONTAINER_PLAYBACKSTATE,
|
|
82
|
+
this.onPlaybackChanged,
|
|
83
|
+
)
|
|
84
|
+
this.listenTo(
|
|
85
|
+
this.container,
|
|
86
|
+
Events.CONTAINER_VOLUME,
|
|
87
|
+
this.onVolumeChanged,
|
|
88
|
+
)
|
|
89
|
+
this.listenTo(this.container, Events.CONTAINER_SEEK, this.onSeek)
|
|
90
|
+
this.listenTo(
|
|
91
|
+
this.container,
|
|
92
|
+
Events.CONTAINER_FULLSCREEN,
|
|
93
|
+
this.onFullscreen,
|
|
94
|
+
)
|
|
95
|
+
this.listenTo(
|
|
96
|
+
this.container,
|
|
97
|
+
Events.CONTAINER_HIGHDEFINITIONUPDATE,
|
|
98
|
+
this.onHD,
|
|
99
|
+
)
|
|
100
|
+
this.listenTo(
|
|
101
|
+
this.container,
|
|
102
|
+
Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
103
|
+
this.onDVR,
|
|
104
|
+
)
|
|
74
105
|
}
|
|
75
|
-
_gaq.push([this.trackerName + '_setAccount', this.account])
|
|
106
|
+
_gaq.push([this.trackerName + '_setAccount', this.account])
|
|
76
107
|
if (this.domainName) {
|
|
77
|
-
_gaq.push([this.trackerName + '_setDomainName', this.domainName])
|
|
108
|
+
_gaq.push([this.trackerName + '_setDomainName', this.domainName])
|
|
78
109
|
}
|
|
79
110
|
}
|
|
80
111
|
|
|
81
112
|
onReady() {
|
|
82
|
-
this.push(['Video', 'Playback', this.container.playback.name])
|
|
113
|
+
this.push(['Video', 'Playback', this.container.playback.name])
|
|
83
114
|
}
|
|
84
115
|
|
|
85
116
|
onPlay() {
|
|
86
|
-
this.push(['Video', 'Play', this.container.playback.src])
|
|
117
|
+
this.push(['Video', 'Play', this.container.playback.src])
|
|
87
118
|
}
|
|
88
119
|
|
|
89
120
|
onStop() {
|
|
90
|
-
this.push(['Video', 'Stop', this.container.playback.src])
|
|
121
|
+
this.push(['Video', 'Stop', this.container.playback.src])
|
|
91
122
|
}
|
|
92
123
|
|
|
93
124
|
onEnded() {
|
|
94
|
-
this.push(['Video', 'Ended', this.container.playback.src])
|
|
125
|
+
this.push(['Video', 'Ended', this.container.playback.src])
|
|
95
126
|
}
|
|
96
127
|
|
|
97
128
|
onBuffering() {
|
|
98
|
-
this.push(['Video', 'Buffering', this.container.playback.src])
|
|
129
|
+
this.push(['Video', 'Buffering', this.container.playback.src])
|
|
99
130
|
}
|
|
100
131
|
|
|
101
132
|
onBufferFull() {
|
|
102
|
-
this.push(['Video', 'Bufferfull', this.container.playback.src])
|
|
133
|
+
this.push(['Video', 'Bufferfull', this.container.playback.src])
|
|
103
134
|
}
|
|
104
135
|
|
|
105
136
|
onError() {
|
|
106
|
-
this.push(['Video', 'Error', this.container.playback.src])
|
|
137
|
+
this.push(['Video', 'Error', this.container.playback.src])
|
|
107
138
|
}
|
|
108
139
|
|
|
109
140
|
onHD(isHD: boolean) {
|
|
110
|
-
const status = isHD ? 'ON': 'OFF'
|
|
141
|
+
const status = isHD ? 'ON' : 'OFF'
|
|
111
142
|
|
|
112
143
|
if (status !== this.currentHDState) {
|
|
113
|
-
this.currentHDState = status
|
|
114
|
-
this.push(['Video', 'HD - ' + status, this.container.playback.src])
|
|
144
|
+
this.currentHDState = status
|
|
145
|
+
this.push(['Video', 'HD - ' + status, this.container.playback.src])
|
|
115
146
|
}
|
|
116
147
|
}
|
|
117
148
|
|
|
118
149
|
private onPlaybackChanged(playbackState: { type: string | null }) {
|
|
119
150
|
if (playbackState.type !== null) {
|
|
120
|
-
this.push([
|
|
151
|
+
this.push([
|
|
152
|
+
'Video',
|
|
153
|
+
'Playback Type - ' + playbackState.type,
|
|
154
|
+
this.container.playback.src,
|
|
155
|
+
])
|
|
121
156
|
}
|
|
122
157
|
}
|
|
123
158
|
|
|
124
159
|
onDVR(dvrInUse: boolean) {
|
|
125
|
-
const status = dvrInUse? 'ON': 'OFF'
|
|
160
|
+
const status = dvrInUse ? 'ON' : 'OFF'
|
|
126
161
|
|
|
127
|
-
this.push(['Interaction', 'DVR - ' + status, this.container.playback.src])
|
|
162
|
+
this.push(['Interaction', 'DVR - ' + status, this.container.playback.src])
|
|
128
163
|
}
|
|
129
164
|
|
|
130
165
|
onPause() {
|
|
131
|
-
this.push(['Video', 'Pause', this.container.playback.src])
|
|
166
|
+
this.push(['Video', 'Pause', this.container.playback.src])
|
|
132
167
|
}
|
|
133
168
|
|
|
134
169
|
onSeek() {
|
|
135
|
-
this.push(['Video', 'Seek', this.container.playback.src])
|
|
170
|
+
this.push(['Video', 'Seek', this.container.playback.src])
|
|
136
171
|
}
|
|
137
172
|
|
|
138
173
|
onVolumeChanged() {
|
|
139
|
-
this.push(['Interaction', 'Volume', this.container.playback.src])
|
|
174
|
+
this.push(['Interaction', 'Volume', this.container.playback.src])
|
|
140
175
|
}
|
|
141
176
|
|
|
142
177
|
onFullscreen() {
|
|
143
|
-
this.push(['Interaction', 'Fullscreen', this.container.playback.src])
|
|
178
|
+
this.push(['Interaction', 'Fullscreen', this.container.playback.src])
|
|
144
179
|
}
|
|
145
180
|
|
|
146
181
|
push(array: string[]) {
|
|
147
|
-
const res = [this.trackerName + '_trackEvent'].concat(array)
|
|
182
|
+
const res = [this.trackerName + '_trackEvent'].concat(array)
|
|
148
183
|
|
|
149
|
-
_gaq.push(res)
|
|
184
|
+
_gaq.push(res)
|
|
150
185
|
}
|
|
151
186
|
}
|