@gcorevideo/player 2.20.1 → 2.20.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 +1328 -1328
- package/dist/index.js +305 -217
- package/dist/player.d.ts +270 -52
- package/dist/plugins/index.css +612 -612
- package/dist/plugins/index.js +1459 -1347
- package/docs/api/player.audioselector.md +1 -251
- package/docs/api/player.bigmutebutton.md +1 -156
- package/docs/api/player.clapprstats.exportmetrics.md +4 -0
- package/docs/api/player.clapprstats.md +7 -223
- package/docs/api/player.clapprstats.setupdatemetrics.md +2 -0
- package/docs/api/player.clicktopause.md +5 -113
- package/docs/api/player.clipsplugin.gettext.md +9 -0
- package/docs/api/player.clipsplugin.md +10 -94
- package/docs/api/player.clipspluginsettings.md +57 -0
- package/docs/api/player.clipspluginsettings.text.md +13 -0
- package/docs/api/player.contextmenu._constructor_.md +6 -3
- package/docs/api/player.contextmenu.md +13 -256
- package/docs/api/player.contextmenupluginsettings.label.md +11 -0
- package/docs/api/player.contextmenupluginsettings.md +93 -0
- package/docs/api/player.contextmenupluginsettings.preventshowcontextmenu.md +11 -0
- package/docs/api/player.contextmenupluginsettings.url.md +11 -0
- package/docs/api/player.dvrcontrols.md +1 -1
- package/docs/api/player.errorscreen.md +0 -2
- package/docs/api/player.favicon._constructor_.md +3 -0
- package/docs/api/player.favicon.bindevents.md +3 -0
- package/docs/api/player.favicon.configure.md +3 -0
- package/docs/api/player.favicon.destroy.md +3 -0
- package/docs/api/player.favicon.disable.md +3 -0
- package/docs/api/player.favicon.md +18 -1
- package/docs/api/player.favicon.name.md +3 -0
- package/docs/api/player.favicon.supportedversion.md +3 -0
- package/docs/api/player.gearevents.md +4 -1
- package/docs/api/player.googleanalytics._constructor_.md +3 -0
- package/docs/api/player.googleanalytics.addeventlisteners.md +3 -0
- package/docs/api/player.googleanalytics.embedscript.md +3 -0
- package/docs/api/player.googleanalytics.md +42 -1
- package/docs/api/player.googleanalytics.name.md +3 -0
- package/docs/api/player.googleanalytics.onbufferfull.md +3 -0
- package/docs/api/player.googleanalytics.onbuffering.md +3 -0
- package/docs/api/player.googleanalytics.ondvr.md +3 -0
- package/docs/api/player.googleanalytics.onended.md +3 -0
- package/docs/api/player.googleanalytics.onerror.md +3 -0
- package/docs/api/player.googleanalytics.onfullscreen.md +3 -0
- package/docs/api/player.googleanalytics.onhd.md +3 -0
- package/docs/api/player.googleanalytics.onpause.md +3 -0
- package/docs/api/player.googleanalytics.onplay.md +3 -0
- package/docs/api/player.googleanalytics.onready.md +3 -0
- package/docs/api/player.googleanalytics.onseek.md +3 -0
- package/docs/api/player.googleanalytics.onstop.md +3 -0
- package/docs/api/player.googleanalytics.onvolumechanged.md +3 -0
- package/docs/api/player.googleanalytics.push.md +3 -0
- package/docs/api/player.googleanalytics.supportedversion.md +3 -0
- package/docs/api/player.initeventdata.event.md +3 -0
- package/docs/api/player.initeventdata.md +7 -0
- package/docs/api/player.logo._constructor_.md +3 -0
- package/docs/api/player.logo.attributes.md +3 -0
- package/docs/api/player.logo.bindevents.md +3 -0
- package/docs/api/player.logo.md +20 -1
- package/docs/api/player.logo.name.md +3 -0
- package/docs/api/player.logo.render.md +3 -0
- package/docs/api/player.logo.stoplistening.md +3 -0
- package/docs/api/player.logo.supportedversion.md +3 -0
- package/docs/api/player.logo.template.md +3 -0
- package/docs/api/player.md +68 -20
- package/docs/api/player.mediacontrolelement.md +1 -1
- package/docs/api/player.multicamera.md +2 -0
- package/docs/api/player.seektime.attributes.md +3 -0
- package/docs/api/player.seektime.bindevents.md +3 -0
- package/docs/api/player.seektime.durationshown.md +3 -0
- package/docs/api/player.seektime.getseektime.md +3 -0
- package/docs/api/player.seektime.islivestreamwithdvr.md +3 -0
- package/docs/api/player.seektime.md +31 -0
- package/docs/api/player.seektime.mediacontrol.md +3 -0
- package/docs/api/player.seektime.mediacontrolcontainer.md +3 -0
- package/docs/api/player.seektime.name.md +3 -0
- package/docs/api/player.seektime.render.md +3 -0
- package/docs/api/player.seektime.shouldbevisible.md +3 -0
- package/docs/api/player.seektime.supportedversion.md +3 -0
- package/docs/api/player.seektime.template.md +3 -0
- package/docs/api/player.seektime.update.md +3 -0
- package/docs/api/player.share.md +2 -0
- package/docs/api/player.skiptime.md +2 -0
- package/docs/api/player.stalleventdata.count.md +3 -0
- package/docs/api/player.stalleventdata.event.md +3 -0
- package/docs/api/player.stalleventdata.md +8 -3
- package/docs/api/player.stalleventdata.time.md +3 -0
- package/docs/api/player.stalleventdata.total_ms.md +3 -0
- package/docs/api/player.starteventdata.event.md +3 -0
- package/docs/api/player.starteventdata.md +7 -0
- package/docs/api/player.telemetryevent.md +11 -0
- package/docs/api/player.telemetryeventdata.md +3 -0
- package/docs/api/player.telemetrypluginsettings.md +4 -1
- package/docs/api/player.telemetrypluginsettings.send.md +3 -0
- package/docs/api/player.telemetryrecord.md +3 -0
- package/docs/api/player.thumbnails.md +21 -139
- package/docs/api/player.thumbnailspluginsettings.md +23 -0
- package/docs/api/player.volumefade.md +1 -0
- package/docs/api/player.watcheventdata.event.md +3 -0
- package/docs/api/player.watcheventdata.md +7 -0
- package/lib/index.plugins.d.ts +0 -1
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +0 -1
- package/lib/plugins/audio-selector/AudioSelector.d.ts +28 -6
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +52 -22
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +18 -2
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +21 -16
- package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +31 -8
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/ClapprStats.js +24 -0
- package/lib/plugins/clappr-stats/types.d.ts +12 -0
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/types.js +3 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts +13 -1
- package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +14 -4
- package/lib/plugins/clips/Clips.d.ts +34 -2
- package/lib/plugins/clips/Clips.d.ts.map +1 -1
- package/lib/plugins/clips/Clips.js +51 -22
- package/lib/plugins/context-menu/ContextMenu.d.ts +40 -13
- package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -1
- package/lib/plugins/context-menu/ContextMenu.js +48 -36
- package/lib/plugins/dvr-controls/DvrControls.d.ts +1 -3
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DvrControls.js +11 -28
- package/lib/plugins/error-screen/ErrorScreen.d.ts +0 -1
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
- package/lib/plugins/error-screen/ErrorScreen.js +0 -1
- package/lib/plugins/favicon/Favicon.d.ts +4 -0
- package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
- package/lib/plugins/favicon/Favicon.js +4 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +4 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -1
- package/lib/plugins/google-analytics/GoogleAnalytics.js +5 -1
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.d.ts.map +1 -1
- package/lib/plugins/index.js +0 -1
- package/lib/plugins/logo/Logo.d.ts +4 -0
- package/lib/plugins/logo/Logo.d.ts.map +1 -1
- package/lib/plugins/logo/Logo.js +4 -0
- package/lib/plugins/media-control/MediaControl.d.ts +1 -1
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +3 -1
- package/lib/plugins/multi-camera/MultiCamera.d.ts +3 -0
- package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
- package/lib/plugins/multi-camera/MultiCamera.js +3 -0
- package/lib/plugins/seek-time/SeekTime.d.ts +4 -0
- package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -1
- package/lib/plugins/seek-time/SeekTime.js +5 -1
- package/lib/plugins/share/Share.d.ts +3 -0
- package/lib/plugins/share/Share.d.ts.map +1 -1
- package/lib/plugins/share/Share.js +3 -0
- package/lib/plugins/skip-time/SkipTime.d.ts +3 -0
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
- package/lib/plugins/skip-time/SkipTime.js +3 -0
- package/lib/plugins/telemetry/Telemetry.d.ts +18 -0
- package/lib/plugins/telemetry/Telemetry.d.ts.map +1 -1
- package/lib/plugins/telemetry/Telemetry.js +1 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts +48 -3
- package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -1
- package/lib/plugins/thumbnails/Thumbnails.js +52 -18
- package/lib/plugins/volume-fade/VolumeFade.d.ts +1 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -1
- package/lib/plugins/volume-fade/VolumeFade.js +1 -0
- package/package.json +1 -1
- package/src/index.plugins.ts +0 -1
- package/src/plugins/audio-selector/AudioSelector.ts +227 -154
- package/src/plugins/big-mute-button/BigMuteButton.ts +100 -79
- package/src/plugins/bottom-gear/BottomGear.ts +1 -0
- package/src/plugins/clappr-stats/ClapprStats.ts +32 -8
- package/src/plugins/clappr-stats/types.ts +13 -0
- package/src/plugins/click-to-pause/ClickToPause.ts +47 -36
- package/src/plugins/clips/Clips.ts +127 -71
- package/src/plugins/context-menu/ContextMenu.ts +105 -76
- package/src/plugins/dvr-controls/DvrControls.ts +11 -30
- package/src/plugins/error-screen/ErrorScreen.ts +0 -1
- package/src/plugins/favicon/Favicon.ts +4 -0
- package/src/plugins/google-analytics/GoogleAnalytics.ts +5 -1
- package/src/plugins/index.ts +0 -1
- package/src/plugins/logo/Logo.ts +4 -0
- package/src/plugins/media-control/MediaControl.ts +4 -1
- package/src/plugins/multi-camera/MultiCamera.ts +3 -0
- package/src/plugins/seek-time/SeekTime.ts +5 -1
- package/src/plugins/share/Share.ts +3 -0
- package/src/plugins/skip-time/SkipTime.ts +3 -0
- package/src/plugins/telemetry/Telemetry.ts +18 -0
- package/src/plugins/thumbnails/Thumbnails.ts +268 -194
- package/src/plugins/volume-fade/VolumeFade.ts +1 -0
- package/temp/player.api.json +622 -2463
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.audioselector.attributes.md +0 -17
- package/docs/api/player.audioselector.bindevents.md +0 -18
- package/docs/api/player.audioselector.events.md +0 -17
- package/docs/api/player.audioselector.hideselecttrackmenu.md +0 -18
- package/docs/api/player.audioselector.name.md +0 -14
- package/docs/api/player.audioselector.onshowlevelselectmenu.md +0 -18
- package/docs/api/player.audioselector.reload.md +0 -18
- package/docs/api/player.audioselector.render.md +0 -18
- package/docs/api/player.audioselector.supportedversion.md +0 -16
- package/docs/api/player.audioselector.template.md +0 -14
- package/docs/api/player.audioselector.togglecontextmenu.md +0 -18
- package/docs/api/player.audioselector.unbindevents.md +0 -18
- package/docs/api/player.audioselector.version.md +0 -14
- package/docs/api/player.bigmutebutton.bindevents.md +0 -18
- package/docs/api/player.bigmutebutton.events.md +0 -17
- package/docs/api/player.bigmutebutton.name.md +0 -14
- package/docs/api/player.bigmutebutton.render.md +0 -18
- package/docs/api/player.bigmutebutton.supportedversion.md +0 -16
- package/docs/api/player.bigmutebutton.template.md +0 -14
- package/docs/api/player.clapprstats._buildreport.md +0 -18
- package/docs/api/player.clapprstats._defaultreport.md +0 -52
- package/docs/api/player.clapprstats._playbackname.md +0 -14
- package/docs/api/player.clapprstats._playbacktype.md +0 -14
- package/docs/api/player.clapprstats.bindevents.md +0 -18
- package/docs/api/player.clapprstats.destroy.md +0 -18
- package/docs/api/player.clapprstats.name.md +0 -14
- package/docs/api/player.clapprstats.onfirstplaying.md +0 -18
- package/docs/api/player.clapprstats.playafterpause.md +0 -18
- package/docs/api/player.clapprstats.starttimers.md +0 -18
- package/docs/api/player.clapprstats.stopreporting.md +0 -18
- package/docs/api/player.clapprstats.supportedversion.md +0 -16
- package/docs/api/player.clicktopause.bindevents.md +0 -15
- package/docs/api/player.clicktopause.config.md +0 -11
- package/docs/api/player.clicktopause.name.md +0 -11
- package/docs/api/player.clicktopause.supportedversion.md +0 -13
- package/docs/api/player.clipsplugin.attributes.md +0 -13
- package/docs/api/player.clipsplugin.bindevents.md +0 -15
- package/docs/api/player.clipsplugin.makesvg.md +0 -49
- package/docs/api/player.clipsplugin.name.md +0 -11
- package/docs/api/player.clipsplugin.unbindevents.md +0 -15
- package/docs/api/player.contextmenu.attributes.md +0 -13
- package/docs/api/player.contextmenu.bindevents.md +0 -15
- package/docs/api/player.contextmenu.destroy.md +0 -15
- package/docs/api/player.contextmenu.events.md +0 -13
- package/docs/api/player.contextmenu.exposeversion.md +0 -14
- package/docs/api/player.contextmenu.label.md +0 -11
- package/docs/api/player.contextmenu.mediacontrol.md +0 -11
- package/docs/api/player.contextmenu.name.md +0 -11
- package/docs/api/player.contextmenu.render.md +0 -15
- package/docs/api/player.contextmenu.supportedversion.md +0 -13
- package/docs/api/player.contextmenu.template.md +0 -11
- package/docs/api/player.contextmenu.url.md +0 -11
- package/docs/api/player.disablecontrols.bindevents.md +0 -15
- package/docs/api/player.disablecontrols.container.md +0 -11
- package/docs/api/player.disablecontrols.md +0 -138
- package/docs/api/player.disablecontrols.name.md +0 -11
- package/docs/api/player.disablecontrols.supportedversion.md +0 -13
- package/docs/api/player.disablecontrols.unbindevents.md +0 -15
- package/docs/api/player.thumbnails.attributes.md +0 -13
- package/docs/api/player.thumbnails.bindevents.md +0 -15
- package/docs/api/player.thumbnails.name.md +0 -11
- package/docs/api/player.thumbnails.settext.md +0 -49
- package/docs/api/player.thumbnails.supportedversion.md +0 -13
- package/docs/api/player.thumbnails.template.md +0 -11
- package/src/plugins/disable-controls/DisableControls.ts +0 -81
- package/src/plugins/ga-events/GaEvents.js +0 -395
- package/src/plugins/ga-events/ga-tracking.js +0 -46
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { UICorePlugin, Events } from '@clappr/core';
|
|
2
|
-
|
|
3
|
-
import { CLAPPR_VERSION } from '../../build.js';
|
|
4
|
-
|
|
5
|
-
export class DisableControls extends UICorePlugin {
|
|
6
|
-
get name() {
|
|
7
|
-
return 'disable_controls';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
get container() {
|
|
11
|
-
return this.core && this.core.activeContainer;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get supportedVersion() {
|
|
15
|
-
return { min: CLAPPR_VERSION };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
override bindEvents() {
|
|
19
|
-
if (this.container) {
|
|
20
|
-
this.listenTo(this.container, Events.CONTAINER_MEDIACONTROL_ENABLE, this.enableControls);
|
|
21
|
-
this.listenTo(this.container, Events.CONTAINER_PLAY, this.enableControls);
|
|
22
|
-
this.listenTo(this.container, Events.CONTAINER_PAUSE, this.enableControls);
|
|
23
|
-
this.listenTo(this.container, Events.CONTAINER_STOP, this.enableControls);
|
|
24
|
-
this.listenTo(this.container, Events.CONTAINER_ENDED, this.enableControls);
|
|
25
|
-
this.listenTo(this.container, 'container:advertisement:start', this.enableControls);
|
|
26
|
-
}
|
|
27
|
-
this.listenTo(this.core, Events.CORE_READY, this.onCoreReady);
|
|
28
|
-
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_SHOW, this.enableControls);
|
|
29
|
-
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.enableControls);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
unbindEvents() {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
this.stopListening(this.core, Events.CORE_READY);
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_SHOW);
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED);
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
this.stopListening(this.container, Events.CONTAINER_MEDIACONTROL_ENABLE);
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
this.stopListening(this.container, Events.CONTAINER_PLAY);
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
this.stopListening(this.container, Events.CONTAINER_PAUSE);
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
this.stopListening(this.container, Events.CONTAINER_STOP);
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
this.stopListening(this.container, Events.CONTAINER_ENDED);
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
this.stopListening(this.container, 'container:advertisement:start');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private setDisableStyles() {
|
|
54
|
-
const css = document.createElement('style');
|
|
55
|
-
|
|
56
|
-
const styles = '.control-need-disable { display: none!important; }';
|
|
57
|
-
|
|
58
|
-
css.appendChild(document.createTextNode(styles));
|
|
59
|
-
|
|
60
|
-
this.core.$el.get(0).appendChild(css);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private onCoreReady() {
|
|
64
|
-
this.setDisableStyles();
|
|
65
|
-
this.bindEvents();
|
|
66
|
-
this.enableControls();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private enableControls() {
|
|
70
|
-
this.disableAllControls();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private disableAllControls() {
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
const spinnerPlugin = this.container.getPlugin('spinner');
|
|
76
|
-
|
|
77
|
-
spinnerPlugin?.destroy();
|
|
78
|
-
this.container.disableMediaControl();
|
|
79
|
-
}, 0);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
// Clappr player is Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
2
|
-
|
|
3
|
-
import { CorePlugin, Events, Playback, $ } from '@clappr/core';
|
|
4
|
-
import gaTrackingSnippet from './ga-tracking';
|
|
5
|
-
|
|
6
|
-
export class GaEvents extends CorePlugin {
|
|
7
|
-
get name() {
|
|
8
|
-
return 'ga_events';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
constructor(core) {
|
|
12
|
-
super(core);
|
|
13
|
-
this._volumeTimer = null;
|
|
14
|
-
this._doSendPlay = true;
|
|
15
|
-
this.readPluginConfig(this.options.gaEventsPlugin);
|
|
16
|
-
gaTrackingSnippet(this._gaCfg.name, this._gaCfg.debug, this._gaCfg.trace);
|
|
17
|
-
this._ga('create', this._trackingId, this._createFieldsObject);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
bindEvents() {
|
|
21
|
-
const eventsToAlwaysBind = [
|
|
22
|
-
{ event: Events.CONTAINER_TIMEUPDATE, handler: this.onTimeUpdate },
|
|
23
|
-
{ event: Events.CONTAINER_PLAY, handler: this.onPlay },
|
|
24
|
-
{ event: Events.CONTAINER_SEEK, handler: (event) => this.onSeek(event) },
|
|
25
|
-
{ event: Events.CONTAINER_PAUSE, handler: this.onPause },
|
|
26
|
-
{ event: Events.CONTAINER_STOP, handler: this.onStop },
|
|
27
|
-
{ event: Events.CONTAINER_ENDED, handler: this.onEnded },
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const conditionalEvents = [
|
|
31
|
-
{ condition: 'ready', event: Events.CONTAINER_READY, handler: this.onReady },
|
|
32
|
-
{ condition: 'buffering', event: Events.CONTAINER_STATE_BUFFERING, handler: this.onBuffering },
|
|
33
|
-
{ condition: 'bufferfull', event: Events.CONTAINER_STATE_BUFFERFULL, handler: this.onBufferFull },
|
|
34
|
-
{ condition: 'loadedmetadata', event: Events.CONTAINER_LOADEDMETADATA, handler: this.onLoadedMetadata },
|
|
35
|
-
{ condition: 'volume', event: Events.CONTAINER_VOLUME, handler: (event) => this.onVolumeChanged(event) },
|
|
36
|
-
{ condition: 'fullscreen', event: Events.CONTAINER_FULLSCREEN, handler: this.onFullscreen },
|
|
37
|
-
{ condition: 'playbackstate', event: Events.CONTAINER_PLAYBACKSTATE, handler: this.onPlaybackChanged },
|
|
38
|
-
{ condition: 'highdefinitionupdate', event: Events.CONTAINER_HIGHDEFINITIONUPDATE, handler: this.onHD },
|
|
39
|
-
{ condition: 'playbackdvrstatechanged', event: Events.CONTAINER_PLAYBACKDVRSTATECHANGED, handler: this.onDVR },
|
|
40
|
-
{ condition: 'error', event: Events.CONTAINER_ERROR, handler: this.onError },
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.containerChanged);
|
|
44
|
-
this._container = this.core.activeContainer;
|
|
45
|
-
if (this._container) {
|
|
46
|
-
// Set resolved source as eventLabel if not defined in plugin configuration
|
|
47
|
-
if (!this._label) {
|
|
48
|
-
this._label = this._container.options.src;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
eventsToAlwaysBind.forEach(({ event, handler }) => {
|
|
52
|
-
this.listenTo(this._container, event, handler);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
conditionalEvents.forEach(({ condition, event, handler }) => {
|
|
56
|
-
if (this._hasEvent(condition)) {
|
|
57
|
-
this.listenTo(this._container, event, handler);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getExternalInterface() {
|
|
64
|
-
// Expose player method only if tracker name is available
|
|
65
|
-
if (this._trackerName) {
|
|
66
|
-
return {
|
|
67
|
-
gaEventsTracker: this.gaTracker
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
containerChanged() {
|
|
75
|
-
this.stopListening();
|
|
76
|
-
this.bindEvents();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get _ga() {
|
|
80
|
-
return window[window.GoogleAnalyticsObject];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
gaTracker() {
|
|
84
|
-
return this._ga.getByName && this._ga.getByName(this._trackerName);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
gaEvent(category, action, label, value) {
|
|
88
|
-
this._ga(this._send, 'event', category, action, label, value);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
gaException(desc, isFatal=false) {
|
|
92
|
-
this._ga(this._send, 'exception', {
|
|
93
|
-
'exDescription': desc,
|
|
94
|
-
'exFatal': isFatal
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
readPluginConfig(cfg) {
|
|
99
|
-
if (!cfg) {
|
|
100
|
-
throw new Error(this.name + ' plugin config is missing');
|
|
101
|
-
}
|
|
102
|
-
if (!cfg.trackingId) {
|
|
103
|
-
throw new Error(this.name + ' plugin "trackingId" required config parameter is missing');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this._gaCfg = cfg.gaCfg || { name: 'ga', debug: false, trace: false };
|
|
107
|
-
this._trackingId = cfg.trackingId;
|
|
108
|
-
this._createFieldsObject = cfg.createFieldsObject;
|
|
109
|
-
this._trackerName = this._createFieldsObject && this._createFieldsObject.name;
|
|
110
|
-
this._send = this._trackerName ? this._trackerName + '.send' : 'send';
|
|
111
|
-
this._category = cfg.eventCategory || 'Video';
|
|
112
|
-
this._label = cfg.eventLabel; // Otherwise filled in bindEvents()
|
|
113
|
-
this._setValue = cfg.eventValueAuto === true;
|
|
114
|
-
this._events = $.isArray(cfg.eventToTrack) && cfg.eventToTrack || this._defaultEvents;
|
|
115
|
-
this._eventMap = $.isPlainObject(cfg.eventMapping) && cfg.eventMapping || this._defaultEventMap;
|
|
116
|
-
this._gaPlayOnce = cfg.sendPlayOnce === true;
|
|
117
|
-
this._gaEx = cfg.sendExceptions === true;
|
|
118
|
-
this._gaExDesc = cfg.sendExceptionsMsg === true;
|
|
119
|
-
|
|
120
|
-
// Add 'error' to tracked events if GA exceptions are enabled
|
|
121
|
-
if (this._gaEx && !this._hasEvent('error')) {
|
|
122
|
-
this._events.push('error');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
this._gaPercent = $.isArray(cfg.progressPercent) && cfg.progressPercent || [];
|
|
126
|
-
this._gaPercentCat = cfg.progressPercentCategory || this._category;
|
|
127
|
-
this._gaPercentAct = $.isFunction(cfg.progressPercentAction) && cfg.progressPercentAction || function(i) {
|
|
128
|
-
return 'progress_' + i + 'p';
|
|
129
|
-
};
|
|
130
|
-
this._processGaPercent = this._gaPercent.length > 0;
|
|
131
|
-
this._gaSeconds = $.isArray(cfg.progressSeconds) && cfg.progressSeconds || [];
|
|
132
|
-
this._gaSecondsCat = cfg.progressSecondsCategory || this._category;
|
|
133
|
-
this._gaSecondsAct = $.isFunction(cfg.progressSecondsAction) && cfg.progressSecondsAction || function(i) {
|
|
134
|
-
return 'progress_' + i + 's';
|
|
135
|
-
};
|
|
136
|
-
this._gaSecondsTimerStarted = false;
|
|
137
|
-
this._processGaSeconds = this._gaSeconds.length > 0;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
get _defaultEventMap() {
|
|
141
|
-
return {
|
|
142
|
-
'ready': 'ready',
|
|
143
|
-
'buffering': 'buffering',
|
|
144
|
-
'bufferfull': 'bufferfull',
|
|
145
|
-
'loadedmetadata': 'loadedmetadata',
|
|
146
|
-
'play': 'play',
|
|
147
|
-
'seek': 'seek',
|
|
148
|
-
'pause': 'pause',
|
|
149
|
-
'stop': 'stop',
|
|
150
|
-
'ended': 'ended',
|
|
151
|
-
'volume': 'volume',
|
|
152
|
-
'fullscreen': 'fullscreen',
|
|
153
|
-
'error': 'error',
|
|
154
|
-
'playbackstate': 'playbackstate',
|
|
155
|
-
'highdefinitionupdate': 'highdefinitionupdate',
|
|
156
|
-
'playbackdvrstatechanged': 'playbackdvrstatechanged'
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
get _defaultEvents() {
|
|
161
|
-
return [
|
|
162
|
-
'play',
|
|
163
|
-
'seek',
|
|
164
|
-
'pause',
|
|
165
|
-
'stop',
|
|
166
|
-
'ended',
|
|
167
|
-
'volume'
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
_hasEvent(e) {
|
|
172
|
-
return this._events.indexOf(e) !== -1;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
_action(e) {
|
|
176
|
-
return this._eventMap[e];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
_value(v) {
|
|
180
|
-
if (this._setValue) {
|
|
181
|
-
return v;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
get position() {
|
|
186
|
-
return this.isLive ? 0 : this._position;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
get duration() {
|
|
190
|
-
return this.isLive ? 0 : this._container && this._container.getDuration();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
get isLive() {
|
|
194
|
-
return this._container.getPlaybackType() === Playback.LIVE;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
get isPlaying() {
|
|
198
|
-
return this._container.isPlaying();
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
trunc(v) {
|
|
202
|
-
return parseInt(v, 10);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
onTimeUpdate(o){
|
|
206
|
-
this._position = o.current && this.trunc(o.current) || 0;
|
|
207
|
-
|
|
208
|
-
if (this.isLive || !this.isPlaying) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Check for "seconds" progress event
|
|
213
|
-
this._processGaSeconds && this.processGaSeconds(this._position);
|
|
214
|
-
|
|
215
|
-
// Check for "percent" progress event
|
|
216
|
-
this._processGaPercent && this.processGaPercent(this._position);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
processGaSeconds(pos) {
|
|
220
|
-
if (this._gaSecondsPrev !== pos && this._gaSeconds.indexOf(pos) !== -1) {
|
|
221
|
-
this._gaSecondsPrev = pos;
|
|
222
|
-
this.gaEvent(this._gaSecondsCat, this._gaSecondsAct(pos), this._label);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
processGaPercent(pos) {
|
|
227
|
-
// FIXME: check if (duration > 0) ?
|
|
228
|
-
const percent = this.trunc((pos * 100) / this.duration);
|
|
229
|
-
|
|
230
|
-
$.each(this._gaPercent, (i, v) => {
|
|
231
|
-
// Percentage value may never match expected value. To fix that, we compare to previous and current.
|
|
232
|
-
// This introduce a small approximation, but this function is called multiples time per seconds.
|
|
233
|
-
if (this._gaPercentPrev < v && percent >= v) {
|
|
234
|
-
this.gaEvent(this._gaPercentCat, this._gaPercentAct(v), this._label);
|
|
235
|
-
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
this._gaPercentPrev = percent;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
onReady() {
|
|
243
|
-
this.gaEvent(this._category, this._action('ready'), this._label);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
onBuffering() {
|
|
247
|
-
this.gaEvent(this._category, this._action('buffering'), this._label);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
onBufferFull() {
|
|
251
|
-
this.gaEvent(this._category, this._action('bufferfull'), this._label);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
onLoadedMetadata() {
|
|
255
|
-
this.gaEvent(this._category, this._action('loadedmetadata'), this._label);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
onPlay() {
|
|
259
|
-
if (this._gaPlayOnce) {
|
|
260
|
-
if (!this._doSendPlay) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
this._doSendPlay = false;
|
|
264
|
-
}
|
|
265
|
-
this.gaEvent(this._category, this._action('play'), this._label, this._value(this.position));
|
|
266
|
-
|
|
267
|
-
// Start "seconds" progress event timer (if LIVE playback type)
|
|
268
|
-
this.isLive && this._processGaSeconds && this._startGaSecondsTimer();
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
_startGaSecondsTimer() {
|
|
272
|
-
if (this._gaSecondsTimerStarted) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
this._gaSecondsTimerStarted = true;
|
|
277
|
-
this._gaSecondsElapsed = 0;
|
|
278
|
-
this.processGaSeconds(this._gaSecondsElapsed);
|
|
279
|
-
this._gaSecondsTimerId = setInterval(() => {
|
|
280
|
-
this._gaSecondsElapsed++;
|
|
281
|
-
this.processGaSeconds(this._gaSecondsElapsed);
|
|
282
|
-
}, 1000);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
_stopGaSecondsTimer() {
|
|
286
|
-
clearInterval(this._gaSecondsTimerId);
|
|
287
|
-
this._gaSecondsPrev = -1;
|
|
288
|
-
this._gaSecondsTimerStarted = false;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
onSeek(pos) {
|
|
292
|
-
if (this._hasEvent('seek')) {
|
|
293
|
-
this.gaEvent(this._category, this._action('seek'), this._label, this._value(this.trunc(pos)));
|
|
294
|
-
}
|
|
295
|
-
if (this._gaPlayOnce) {
|
|
296
|
-
this._doSendPlay = true;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Adjust previous "percent" event value
|
|
300
|
-
if (!this.isLive && this._processGaPercent) {
|
|
301
|
-
this._gaPercentPrev = this.trunc((this.trunc(pos) * 100) / this.duration) - 1;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Stop "seconds" progress event timer (if LIVE playback type)
|
|
305
|
-
this.isLive && this._processGaSeconds && this._stopGaSecondsTimer();
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
onPause() {
|
|
309
|
-
if (this._hasEvent('pause')) {
|
|
310
|
-
this.gaEvent(this._category, this._action('pause'), this._label, this._value(this.position));
|
|
311
|
-
}
|
|
312
|
-
if (this._gaPlayOnce) {
|
|
313
|
-
this._doSendPlay = true;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Stop "seconds" progress event timer (if LIVE playback type)
|
|
317
|
-
this.isLive && this._processGaSeconds && this._stopGaSecondsTimer();
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
onStop() {
|
|
321
|
-
if (this._hasEvent('stop')) {
|
|
322
|
-
this.gaEvent(this._category, this._action('stop'), this._label, this._value(this.position));
|
|
323
|
-
}
|
|
324
|
-
if (this._gaPlayOnce) {
|
|
325
|
-
this._doSendPlay = true;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Stop "seconds" progress event timer (if LIVE playback type)
|
|
329
|
-
this.isLive && this._processGaSeconds && this._stopGaSecondsTimer();
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
onEnded() {
|
|
333
|
-
if (this._hasEvent('ended')) {
|
|
334
|
-
this.gaEvent(this._category, this._action('ended'), this._label, this._value(this.position));
|
|
335
|
-
}
|
|
336
|
-
if (this._gaPlayOnce) {
|
|
337
|
-
this._doSendPlay = true;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Check for video ended progress events
|
|
341
|
-
this._processGaSeconds && this.processGaSeconds(this.duration);
|
|
342
|
-
this._processGaPercent && this.processGaPercent(this.duration);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
onVolumeChanged(e) {
|
|
346
|
-
// Rate limit to avoid HTTP hammering
|
|
347
|
-
clearTimeout(this._volumeTimer);
|
|
348
|
-
this._volumeTimer = setTimeout(() => {
|
|
349
|
-
this.gaEvent(this._category, this._action('volume'), this._label, this._value(this.trunc(e)));
|
|
350
|
-
}, 400);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
onFullscreen() {
|
|
354
|
-
this.gaEvent(this._category, this._action('fullscreen'), this._label);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
onPlaybackChanged() {
|
|
358
|
-
this.gaEvent(this._category, this._action('playbackstate'), this._label);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
onHD() {
|
|
362
|
-
this.gaEvent(this._category, this._action('highdefinitionupdate'), this._label);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
onDVR() {
|
|
366
|
-
this.gaEvent(this._category, this._action('playbackdvrstatechanged'), this._label);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
resolveErrMsg(o) {
|
|
370
|
-
if (!this._gaExDesc) {
|
|
371
|
-
return 'error';
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
let msg;
|
|
375
|
-
|
|
376
|
-
if (typeof o.error === 'string') {
|
|
377
|
-
msg = o.error;
|
|
378
|
-
} else if ($.isPlainObject(o.error) && o.error.message) {
|
|
379
|
-
msg = o.error.message;
|
|
380
|
-
} else {
|
|
381
|
-
// FIXME: find out a more elegant way
|
|
382
|
-
msg = 'Error: ' + o.error;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
return msg;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
onError(errorObj) {
|
|
389
|
-
if (this._gaEx) {
|
|
390
|
-
this.gaException(this.resolveErrMsg(errorObj), true);
|
|
391
|
-
} else {
|
|
392
|
-
this.gaEvent(this._category, this._action('error'), this._label);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Based on Google Analytics JavaScript Tracking Snippet
|
|
2
|
-
// See original @ https://developers.google.com/analytics/devguides/collection/analyticsjs/tracking-snippet-reference
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates a temporary global ga object and lazy loads analytics.js.
|
|
6
|
-
* @function
|
|
7
|
-
* @param {string} Global name of analytics object. Defaults to 'ga'.
|
|
8
|
-
* @param {boolean} Set to true to load the debug version of the analytics.js library.
|
|
9
|
-
* @param {boolean} Set to true to enable trace debugging.
|
|
10
|
-
*/
|
|
11
|
-
export default function(name='ga', debug, trace) {
|
|
12
|
-
// Preserve renaming support and minification
|
|
13
|
-
const win = window, doc = document, el = 'script';
|
|
14
|
-
|
|
15
|
-
// Ensure analytics.js is not already loaded
|
|
16
|
-
if (win[name]) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (trace) {
|
|
21
|
-
win['ga_debug'] = { trace: true };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Acts as a pointer to support renaming
|
|
25
|
-
win.GoogleAnalyticsObject = name;
|
|
26
|
-
|
|
27
|
-
// Creates an initial ga() function
|
|
28
|
-
// The queued commands will be executed once analytics.js loads
|
|
29
|
-
win[name] = function() {
|
|
30
|
-
win[name].q.push(arguments);
|
|
31
|
-
};
|
|
32
|
-
win[name].q = [];
|
|
33
|
-
|
|
34
|
-
// Sets the time (as an integer) this tag was executed
|
|
35
|
-
// Used for timing hits
|
|
36
|
-
win[name].l = 1 * new Date();
|
|
37
|
-
|
|
38
|
-
// Insert script element above the first script element in document
|
|
39
|
-
// (async + https)
|
|
40
|
-
const first = doc.getElementsByTagName(el)[0];
|
|
41
|
-
const script = doc.createElement(el);
|
|
42
|
-
|
|
43
|
-
script.src = 'https://www.google-analytics.com/analytics' + (debug ? '_debug.js' : '.js');
|
|
44
|
-
script.async = true;
|
|
45
|
-
first.parentNode.insertBefore(script, first);
|
|
46
|
-
}
|