@vouchfor/embeds 0.0.0-experiment.2da2c49 → 0.0.0-experiment.2dc922f
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/es/embeds.js +1038 -9
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +4 -3
- package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +3 -2
- package/dist/es/src/components/DialogEmbed/index.d.ts +5 -3
- package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +4 -3
- package/dist/es/src/components/PlayerEmbed/controllers/fetcher.d.ts +3 -2
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +4 -2
- package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +4 -3
- package/dist/es/src/components/PlayerEmbed/index.d.ts +76 -0
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +4 -2
- package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
- package/dist/iife/dialog-embed/embed.iife.js +2752 -394
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +2752 -394
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +2726 -370
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +44 -38
- package/src/components/DialogEmbed/Dialog.stories.ts +12 -0
- package/src/components/DialogEmbed/DialogOverlay.ts +2 -1
- package/src/components/DialogEmbed/DialogPortal.ts +22 -10
- package/src/components/DialogEmbed/index.ts +5 -1
- package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
- package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +18 -2
- package/src/components/PlayerEmbed/controllers/tracking/index.ts +10 -10
- package/src/components/PlayerEmbed/controllers/tracking/utils.ts +1 -1
- package/src/components/PlayerEmbed/index.ts +123 -7
- package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +14 -7
- package/src/components/PlayerEmbed/tests/data.ts +121 -77
- package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
- package/dist/es/browser-17f8a53b.js +0 -433
- package/dist/es/browser-17f8a53b.js.map +0 -1
- package/dist/es/index-747e8b52.js +0 -10478
- package/dist/es/index-747e8b52.js.map +0 -1
- package/dist/iife/dialog-embed/browser-2436b04a.js +0 -433
- package/dist/iife/dialog-embed/browser-2436b04a.js.map +0 -1
- package/dist/iife/dialog-embed/embed.js +0 -5
- package/dist/iife/dialog-embed/embed.js.map +0 -1
- package/dist/iife/dialog-embed/index-c39a015a.js +0 -32937
- package/dist/iife/dialog-embed/index-c39a015a.js.map +0 -1
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
- package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +0 -35
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
- package/dist/iife/dialog-embed/src/index.d.ts +0 -2
- package/dist/iife/dialog-embed/src/utils/env.d.ts +0 -12
- package/dist/iife/dialog-embed/src/utils/events.d.ts +0 -2
- package/dist/iife/player-embed/browser-88dbf1ce.js +0 -433
- package/dist/iife/player-embed/browser-88dbf1ce.js.map +0 -1
- package/dist/iife/player-embed/embed.js +0 -5
- package/dist/iife/player-embed/embed.js.map +0 -1
- package/dist/iife/player-embed/index-601226fd.js +0 -32494
- package/dist/iife/player-embed/index-601226fd.js.map +0 -1
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
- package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +0 -35
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
- package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
- package/dist/iife/player-embed/src/index.d.ts +0 -2
- package/dist/iife/player-embed/src/utils/env.d.ts +0 -12
- package/dist/iife/player-embed/src/utils/events.d.ts +0 -2
- package/src/mixins/media-player-proxy.ts +0 -116
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vouchfor/embeds",
|
|
3
|
-
"version": "0.0.0-experiment.
|
|
3
|
+
"version": "0.0.0-experiment.2dc922f",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Aaron Williams",
|
|
6
6
|
"main": "dist/es/embeds.js",
|
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
"tag": "experiment",
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.18.0"
|
|
20
|
+
},
|
|
18
21
|
"scripts": {
|
|
19
22
|
"build": "rm -rf dist && tsc && yarn build:self",
|
|
20
23
|
"build:deps": "yarn --cwd ../media-player build",
|
|
21
24
|
"build:self": "vite build --mode iife && vite build --mode es && node scripts/build.cjs",
|
|
22
25
|
"build:package": "yarn build",
|
|
23
|
-
"build:storybook": "yarn prebuild && storybook build",
|
|
26
|
+
"build:storybook": "turbo run build:package --filter=@vouchfor/embeds^... && yarn prebuild && storybook build",
|
|
24
27
|
"generate:manifest": "wca src --outFile custom-elements.json",
|
|
25
28
|
"lint": "eslint . --quiet",
|
|
26
29
|
"lint:fix": "eslint . --fix",
|
|
@@ -28,9 +31,11 @@
|
|
|
28
31
|
"prepublishOnly": "yarn build",
|
|
29
32
|
"size": "size-limit",
|
|
30
33
|
"storybook": "yarn prebuild && storybook dev -p 6007",
|
|
31
|
-
"prebuild": "yarn
|
|
34
|
+
"prebuild": "yarn generate:manifest",
|
|
32
35
|
"test": "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
|
|
33
|
-
"test:ci": "yarn test --config web-test-runner.ci.config.js"
|
|
36
|
+
"test:ci": "yarn test --config web-test-runner.ci.config.js",
|
|
37
|
+
"test:watch": "yarn test --watch",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
34
39
|
},
|
|
35
40
|
"lint-staged": {
|
|
36
41
|
"**/*.{ts,tsx,js}": "eslint --fix --quiet",
|
|
@@ -38,46 +43,47 @@
|
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
45
|
"@a11y/focus-trap": "^1.0.5",
|
|
41
|
-
"@lit/task": "^1.0.
|
|
42
|
-
"@vouchfor/
|
|
46
|
+
"@lit/task": "^1.0.2",
|
|
47
|
+
"@vouchfor/canvas-video": "0.0.0-experiment.2dc922f",
|
|
48
|
+
"@vouchfor/media-player": "0.0.0-experiment.2dc922f",
|
|
43
49
|
"uuid": "^9.0.1"
|
|
44
50
|
},
|
|
45
51
|
"peerDependencies": {
|
|
46
|
-
"lit": "^3.1.
|
|
52
|
+
"lit": "^3.1.2"
|
|
47
53
|
},
|
|
48
54
|
"devDependencies": {
|
|
49
|
-
"@esm-bundle/chai": "^4.3.4
|
|
50
|
-
"@open-wc/testing": "^
|
|
51
|
-
"@storybook/addon-essentials": "^
|
|
52
|
-
"@storybook/addon-links": "^
|
|
53
|
-
"@storybook/blocks": "^
|
|
54
|
-
"@storybook/web-components": "^
|
|
55
|
-
"@storybook/web-components-vite": "^
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@web/
|
|
63
|
-
"@web/test-runner
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"glob": "^10.
|
|
68
|
-
"lint-staged": "^
|
|
69
|
-
"lit": "^3.
|
|
55
|
+
"@esm-bundle/chai": "^4.3.4",
|
|
56
|
+
"@open-wc/testing": "^4.0.0",
|
|
57
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
58
|
+
"@storybook/addon-links": "^8.6.12",
|
|
59
|
+
"@storybook/blocks": "^8.6.12",
|
|
60
|
+
"@storybook/web-components": "^8.6.12",
|
|
61
|
+
"@storybook/web-components-vite": "^8.6.12",
|
|
62
|
+
"@svgr/core": "^8.1.0",
|
|
63
|
+
"@types/flat": "^5.0.5",
|
|
64
|
+
"@types/mocha": "^10.0.10",
|
|
65
|
+
"@vouchfor/eslint-config": "^1.0.5",
|
|
66
|
+
"@vouchfor/prettier-config": "^1.0.1",
|
|
67
|
+
"@vouchfor/video-utils": "0.0.0-experiment.2dc922f",
|
|
68
|
+
"@web/dev-server-esbuild": "^1.0.4",
|
|
69
|
+
"@web/test-runner": "^0.20.1",
|
|
70
|
+
"@web/test-runner-browserstack": "^0.8.0",
|
|
71
|
+
"@web/test-runner-mocha": "^0.9.0",
|
|
72
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
73
|
+
"glob": "^10.4.5",
|
|
74
|
+
"lint-staged": "^15.5.1",
|
|
75
|
+
"lit": "^3.3.0",
|
|
70
76
|
"lodash": "^4.17.21",
|
|
71
|
-
"
|
|
72
|
-
"react": "^18.
|
|
73
|
-
"
|
|
74
|
-
"rollup-plugin-internal": "^1.0.4",
|
|
77
|
+
"react": "^18.3.1",
|
|
78
|
+
"react-dom": "^18.3.1",
|
|
79
|
+
"rollup-plugin-tla": "^0.0.2",
|
|
75
80
|
"sinon": "^17.0.1",
|
|
76
|
-
"storybook": "^
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"vite
|
|
80
|
-
"vite-plugin-
|
|
81
|
-
"
|
|
81
|
+
"storybook": "^8.6.12",
|
|
82
|
+
"svgson": "^5.3.1",
|
|
83
|
+
"typescript": "^5.8.3",
|
|
84
|
+
"vite": "^5.4.18",
|
|
85
|
+
"vite-plugin-commonjs": "^0.10.4",
|
|
86
|
+
"vite-plugin-dts": "^3.9.1",
|
|
87
|
+
"web-component-analyzer": "^2.0.0"
|
|
82
88
|
}
|
|
83
89
|
}
|
|
@@ -35,6 +35,18 @@ const _DialogEmbed = ({
|
|
|
35
35
|
aspectRatio=${ifDefined(aspectRatio)}
|
|
36
36
|
@error=${console.log}
|
|
37
37
|
></vouch-embed-dialog>
|
|
38
|
+
<vouch-embed-dialog
|
|
39
|
+
env=${ifDefined(env)}
|
|
40
|
+
apiKey=${ifDefined(apiKey)}
|
|
41
|
+
vouchId=${ifDefined(vouchId)}
|
|
42
|
+
templateId=${ifDefined(templateId)}
|
|
43
|
+
.questions=${questions}
|
|
44
|
+
.controls=${controls}
|
|
45
|
+
?autoplay=${autoplay}
|
|
46
|
+
preload=${ifDefined(preload)}
|
|
47
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
|
48
|
+
@error=${console.log}
|
|
49
|
+
></vouch-embed-dialog>
|
|
38
50
|
</div>
|
|
39
51
|
`;
|
|
40
52
|
};
|
|
@@ -21,10 +21,11 @@ class DialogOverlay extends LitElement {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
.container {
|
|
24
|
-
position:
|
|
24
|
+
position: fixed;
|
|
25
25
|
display: flex;
|
|
26
26
|
inset: 0;
|
|
27
27
|
opacity: 1;
|
|
28
|
+
z-index: 2147483647;
|
|
28
29
|
align-items: center;
|
|
29
30
|
justify-content: center;
|
|
30
31
|
transition: opacity 100ms ease-in;
|
|
@@ -29,19 +29,25 @@ class DialogPortal extends LitElement {
|
|
|
29
29
|
|
|
30
30
|
@state() open = false;
|
|
31
31
|
|
|
32
|
-
private _handleToggle = () => {
|
|
33
|
-
this
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
private _handleToggle = ({ detail }: CustomEvent<string>) => {
|
|
33
|
+
// Because we have to attach this listener to the document since this element is portalled outside of the button,
|
|
34
|
+
// we also have to make sure that this player is actually the one we want to open and play by passing in an ID
|
|
35
|
+
// from the button wrapper parent and checking against that same ID we pass as the event detail
|
|
36
|
+
if (this.id === detail) {
|
|
37
|
+
this.open = !this.open;
|
|
38
|
+
|
|
39
|
+
if (this.open) {
|
|
40
|
+
if (!this.disableAutoplay && this._mediaPlayerRef?.value) {
|
|
41
|
+
this._mediaPlayerRef.value.muted = false;
|
|
42
|
+
this._mediaPlayerRef.value.play();
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
this._mediaPlayerRef?.value?.pause();
|
|
39
46
|
}
|
|
40
|
-
} else {
|
|
41
|
-
this._mediaPlayerRef?.value?.pause();
|
|
42
47
|
}
|
|
43
48
|
};
|
|
44
49
|
|
|
50
|
+
// We could do the same thing on close and check for the correct ID but it doesn't really matter
|
|
45
51
|
private _handleClose = () => {
|
|
46
52
|
this.open = false;
|
|
47
53
|
this._mediaPlayerRef?.value?.pause();
|
|
@@ -70,7 +76,13 @@ class DialogPortal extends LitElement {
|
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
|
73
|
-
|
|
79
|
+
// We must create a new node here because portalling into the same node (document.body) causes the second
|
|
80
|
+
// element to overwrite the first for some reason (not behaviour really stated in the docs)
|
|
81
|
+
// I am fairly certain this function is only run once as the default behaviour creates the open shadow root
|
|
82
|
+
// and returns that shadow root in this function: https://lit.dev/docs/components/shadow-dom/#implementing-createrenderroot
|
|
83
|
+
const newNode = document.createElement('div');
|
|
84
|
+
document.body.appendChild(newNode);
|
|
85
|
+
return newNode;
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
render() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css, html, LitElement } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
5
|
|
|
5
6
|
import type { PlayerEmbedProps } from '../PlayerEmbed';
|
|
6
7
|
|
|
@@ -41,8 +42,10 @@ class DialogEmbed extends LitElement {
|
|
|
41
42
|
@property({ type: Boolean }) disableAutoplay: DialogEmbedProps['disableAutoplay'] = false;
|
|
42
43
|
@property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
|
|
43
44
|
|
|
45
|
+
private _id = uuidv4();
|
|
46
|
+
|
|
44
47
|
private _handleRootClick = () => {
|
|
45
|
-
this.dispatchEvent(new CustomEvent('dialogembed:click', { bubbles: true, composed: true }));
|
|
48
|
+
this.dispatchEvent(new CustomEvent('dialogembed:click', { detail: this._id, bubbles: true, composed: true }));
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
connectedCallback(): void {
|
|
@@ -61,6 +64,7 @@ class DialogEmbed extends LitElement {
|
|
|
61
64
|
<vmp-button size="large">Play</vmp-button>
|
|
62
65
|
</slot>
|
|
63
66
|
<vouch-embed-dialog-portal
|
|
67
|
+
id=${this._id}
|
|
64
68
|
?autoplay=${false}
|
|
65
69
|
vouchId=${ifDefined(this.vouchId)}
|
|
66
70
|
templateId=${ifDefined(this.templateId)}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
|
|
4
|
+
import type { PlayerEmbedProps } from '.';
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
6
|
+
|
|
7
|
+
import '.';
|
|
8
|
+
|
|
9
|
+
type MultiEmbedArgs = PlayerEmbedProps & {
|
|
10
|
+
apiKey1?: string;
|
|
11
|
+
apiKey2?: string;
|
|
12
|
+
apiKey3?: string;
|
|
13
|
+
vouchId1?: string;
|
|
14
|
+
vouchId2?: string;
|
|
15
|
+
vouchId3?: string;
|
|
16
|
+
showVouch?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const _MultiEmbed = ({
|
|
20
|
+
vouchId1,
|
|
21
|
+
vouchId2,
|
|
22
|
+
vouchId3,
|
|
23
|
+
templateId,
|
|
24
|
+
questions,
|
|
25
|
+
preload,
|
|
26
|
+
autoplay,
|
|
27
|
+
env,
|
|
28
|
+
apiKey1,
|
|
29
|
+
apiKey2,
|
|
30
|
+
apiKey3,
|
|
31
|
+
controls,
|
|
32
|
+
aspectRatio
|
|
33
|
+
}: MultiEmbedArgs) => {
|
|
34
|
+
return html`
|
|
35
|
+
<div style="height: 33vh">
|
|
36
|
+
<vouch-embed-player
|
|
37
|
+
env=${ifDefined(env)}
|
|
38
|
+
apiKey=${ifDefined(apiKey1)}
|
|
39
|
+
vouchId=${ifDefined(vouchId1)}
|
|
40
|
+
templateId=${ifDefined(templateId)}
|
|
41
|
+
.questions=${questions}
|
|
42
|
+
.controls=${controls}
|
|
43
|
+
?autoplay=${autoplay}
|
|
44
|
+
preload=${ifDefined(preload)}
|
|
45
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
|
46
|
+
@error=${console.log}
|
|
47
|
+
></vouch-embed-player>
|
|
48
|
+
</div>
|
|
49
|
+
<div style="height: 33vh">
|
|
50
|
+
<vouch-embed-player
|
|
51
|
+
env=${ifDefined(env)}
|
|
52
|
+
apiKey=${ifDefined(apiKey2)}
|
|
53
|
+
vouchId=${ifDefined(vouchId2)}
|
|
54
|
+
templateId=${ifDefined(templateId)}
|
|
55
|
+
.questions=${questions}
|
|
56
|
+
.controls=${controls}
|
|
57
|
+
?autoplay=${autoplay}
|
|
58
|
+
preload=${ifDefined(preload)}
|
|
59
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
|
60
|
+
@error=${console.log}
|
|
61
|
+
></vouch-embed-player>
|
|
62
|
+
</div>
|
|
63
|
+
<div style="height: 33vh">
|
|
64
|
+
<vouch-embed-player
|
|
65
|
+
env=${ifDefined(env)}
|
|
66
|
+
apiKey=${ifDefined(apiKey3)}
|
|
67
|
+
vouchId=${ifDefined(vouchId3)}
|
|
68
|
+
templateId=${ifDefined(templateId)}
|
|
69
|
+
.questions=${questions}
|
|
70
|
+
.controls=${controls}
|
|
71
|
+
?autoplay=${autoplay}
|
|
72
|
+
preload=${ifDefined(preload)}
|
|
73
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
|
74
|
+
@error=${console.log}
|
|
75
|
+
></vouch-embed-player>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction
|
|
81
|
+
const meta = {
|
|
82
|
+
title: 'Embeds',
|
|
83
|
+
tags: ['autodocs'],
|
|
84
|
+
render: (args) => _MultiEmbed(args),
|
|
85
|
+
component: 'vouch-embed-player'
|
|
86
|
+
} satisfies Meta<PlayerEmbedProps>;
|
|
87
|
+
|
|
88
|
+
type Story = StoryObj<MultiEmbedArgs>;
|
|
89
|
+
|
|
90
|
+
const MultiPlayer: Story = {
|
|
91
|
+
args: {
|
|
92
|
+
env: 'dev',
|
|
93
|
+
apiKey1: 'TVik9uTMgE-PD25UTHIS6gyl0hMBWC7AT4dkpdlLBT4VIfDWZJrQiCk6Ak7m1',
|
|
94
|
+
vouchId1: '6JQEIPeStt',
|
|
95
|
+
apiKey2: 'TVik9uTMgE-PD25UTHIS6gyl0hMBWC7AT4dkpdlLBT4VIfDWZJrQiCk6Ak7m1',
|
|
96
|
+
vouchId2: '6JQEIPeStt',
|
|
97
|
+
apiKey3: 'TVik9uTMgE-PD25UTHIS6gyl0hMBWC7AT4dkpdlLBT4VIfDWZJrQiCk6Ak7m1',
|
|
98
|
+
vouchId3: '6JQEIPeStt',
|
|
99
|
+
templateId: '357fc118-e179-4171-9446-ff2b8e9d1b29',
|
|
100
|
+
questions: [],
|
|
101
|
+
aspectRatio: 0,
|
|
102
|
+
preload: 'none',
|
|
103
|
+
autoplay: false,
|
|
104
|
+
controls: [
|
|
105
|
+
'progress',
|
|
106
|
+
'play-large',
|
|
107
|
+
'navigation',
|
|
108
|
+
'play',
|
|
109
|
+
'volume',
|
|
110
|
+
'current-time',
|
|
111
|
+
'duration',
|
|
112
|
+
'speed',
|
|
113
|
+
'captions',
|
|
114
|
+
'fullscreen',
|
|
115
|
+
'preview',
|
|
116
|
+
'languages'
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
argTypes: {
|
|
120
|
+
env: {
|
|
121
|
+
control: 'radio',
|
|
122
|
+
options: ['local', 'dev', 'staging', 'prod']
|
|
123
|
+
},
|
|
124
|
+
preload: {
|
|
125
|
+
control: 'radio',
|
|
126
|
+
options: ['auto', 'none']
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
parameters: {
|
|
130
|
+
layout: 'fullscreen'
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default meta;
|
|
135
|
+
export { MultiPlayer };
|
|
@@ -19,7 +19,8 @@ const _PlayerEmbed = ({
|
|
|
19
19
|
env,
|
|
20
20
|
apiKey,
|
|
21
21
|
controls,
|
|
22
|
-
aspectRatio
|
|
22
|
+
aspectRatio,
|
|
23
|
+
senderId
|
|
23
24
|
}: PlayerEmbedArgs) => {
|
|
24
25
|
return html`
|
|
25
26
|
<div style="height: 100vh">
|
|
@@ -33,6 +34,7 @@ const _PlayerEmbed = ({
|
|
|
33
34
|
?autoplay=${autoplay}
|
|
34
35
|
preload=${ifDefined(preload)}
|
|
35
36
|
aspectRatio=${ifDefined(aspectRatio)}
|
|
37
|
+
senderId=${ifDefined(senderId)}
|
|
36
38
|
@error=${console.log}
|
|
37
39
|
></vouch-embed-player>
|
|
38
40
|
</div>
|
|
@@ -58,7 +60,21 @@ const Player: Story = {
|
|
|
58
60
|
questions: [],
|
|
59
61
|
aspectRatio: 0,
|
|
60
62
|
preload: 'none',
|
|
61
|
-
autoplay: false
|
|
63
|
+
autoplay: false,
|
|
64
|
+
controls: [
|
|
65
|
+
'progress',
|
|
66
|
+
'play-large',
|
|
67
|
+
'navigation',
|
|
68
|
+
'play',
|
|
69
|
+
'volume',
|
|
70
|
+
'current-time',
|
|
71
|
+
'duration',
|
|
72
|
+
'speed',
|
|
73
|
+
'captions',
|
|
74
|
+
'fullscreen',
|
|
75
|
+
'preview',
|
|
76
|
+
'languages'
|
|
77
|
+
]
|
|
62
78
|
},
|
|
63
79
|
argTypes: {
|
|
64
80
|
env: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PlayerEmbed } from '../..';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MediaEventDetail } from '@vouchfor/media-player';
|
|
3
3
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
4
4
|
|
|
5
5
|
import { findVouchId, getReportingMetadata, getUids } from './utils';
|
|
@@ -15,6 +15,7 @@ type TrackingPayload = {
|
|
|
15
15
|
answerId?: string;
|
|
16
16
|
streamStart?: number;
|
|
17
17
|
streamEnd?: number;
|
|
18
|
+
senderId?: string;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
type BatchEvent = {
|
|
@@ -41,7 +42,7 @@ class TrackingController implements ReactiveController {
|
|
|
41
42
|
private _answersViewed: BooleanMap = {};
|
|
42
43
|
private _streamStartTime: TimeMap = {};
|
|
43
44
|
private _streamLatestTime: TimeMap = {};
|
|
44
|
-
private _currentlyPlayingVideo:
|
|
45
|
+
private _currentlyPlayingVideo: MediaEventDetail | null = null;
|
|
45
46
|
|
|
46
47
|
constructor(host: PlayerEmbedHost) {
|
|
47
48
|
this.host = host;
|
|
@@ -59,6 +60,7 @@ class TrackingController implements ReactiveController {
|
|
|
59
60
|
event,
|
|
60
61
|
payload: {
|
|
61
62
|
...payload,
|
|
63
|
+
senderId: this.host.senderId,
|
|
62
64
|
vouchId,
|
|
63
65
|
time: new Date().toISOString()
|
|
64
66
|
}
|
|
@@ -127,14 +129,12 @@ class TrackingController implements ReactiveController {
|
|
|
127
129
|
private _handlePlay = () => {
|
|
128
130
|
// Only send the video played event once per session
|
|
129
131
|
if (!this._hasPlayed) {
|
|
130
|
-
this._createTrackingEvent('VIDEO_PLAYED', {
|
|
131
|
-
streamStart: this.host.currentTime
|
|
132
|
-
});
|
|
132
|
+
this._createTrackingEvent('VIDEO_PLAYED', { streamStart: this.host.currentTime });
|
|
133
133
|
this._hasPlayed = true;
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
private _handleVideoPlay = ({ detail: { id, key } }: CustomEvent<
|
|
137
|
+
private _handleVideoPlay = ({ detail: { id, key } }: CustomEvent<MediaEventDetail>) => {
|
|
138
138
|
// Only increment play count once per session
|
|
139
139
|
if (!this._answersViewed[key]) {
|
|
140
140
|
this._createTrackingEvent('VOUCH_RESPONSE_VIEWED', {
|
|
@@ -144,12 +144,12 @@ class TrackingController implements ReactiveController {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
private _handleVideoTimeUpdate = ({ detail: { id, key, node } }: CustomEvent<
|
|
147
|
+
private _handleVideoTimeUpdate = ({ detail: { id, key, node } }: CustomEvent<MediaEventDetail>) => {
|
|
148
148
|
if (
|
|
149
149
|
// We only want to count any time that the video is actually playing
|
|
150
|
-
!this.host.paused
|
|
150
|
+
!this.host.paused
|
|
151
151
|
// Only update the latest time if this event fires for the currently active video
|
|
152
|
-
id === this.host.scene?.video?.id
|
|
152
|
+
// id === this.host.scene?.video?.id
|
|
153
153
|
) {
|
|
154
154
|
this._currentlyPlayingVideo = { id, key, node };
|
|
155
155
|
this._streamLatestTime[key] = node.currentTime;
|
|
@@ -161,7 +161,7 @@ class TrackingController implements ReactiveController {
|
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
private _handleVideoPause = ({ detail: { id, key } }: CustomEvent<
|
|
164
|
+
private _handleVideoPause = ({ detail: { id, key } }: CustomEvent<MediaEventDetail>) => {
|
|
165
165
|
if (this._streamLatestTime[key] > this._streamStartTime[key] + MINIMUM_SEND_THRESHOLD) {
|
|
166
166
|
this._createTrackingEvent('VIDEO_STREAMED', {
|
|
167
167
|
answerId: id,
|
|
@@ -2,7 +2,7 @@ import { TEMPLATE_VERSION } from '@vouchfor/canvas-video';
|
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
|
|
4
4
|
import type { TrackingPayload } from '.';
|
|
5
|
-
import type { Vouch } from '@vouchfor/
|
|
5
|
+
import type { Vouch } from '@vouchfor/video-utils';
|
|
6
6
|
import type { Environment } from '~/utils/env';
|
|
7
7
|
|
|
8
8
|
import packageJson from '~/../package.json';
|