@vouchfor/embeds 0.0.0-experiment.8b3b1df → 0.0.0-experiment.8b8f3c7

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.
Files changed (64) hide show
  1. package/dist/es/embeds.js +1150 -9
  2. package/dist/es/embeds.js.map +1 -1
  3. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +2 -1
  4. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +2 -1
  5. package/dist/es/src/components/DialogEmbed/index.d.ts +4 -1
  6. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +1 -1
  7. package/dist/es/src/components/PlayerEmbed/index.d.ts +77 -0
  8. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +1 -1
  9. package/dist/iife/dialog-embed/embed.iife.js +401 -365
  10. package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
  11. package/dist/iife/embeds.iife.js +401 -365
  12. package/dist/iife/embeds.iife.js.map +1 -1
  13. package/dist/iife/player-embed/embed.iife.js +375 -341
  14. package/dist/iife/player-embed/embed.iife.js.map +1 -1
  15. package/package.json +36 -31
  16. package/src/components/DialogEmbed/Dialog.stories.ts +12 -0
  17. package/src/components/DialogEmbed/DialogOverlay.ts +2 -1
  18. package/src/components/DialogEmbed/DialogPortal.ts +22 -10
  19. package/src/components/DialogEmbed/index.ts +5 -1
  20. package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
  21. package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +15 -1
  22. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +1 -1
  23. package/src/components/PlayerEmbed/index.ts +122 -6
  24. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +1 -1
  25. package/src/components/PlayerEmbed/tests/data.ts +24 -24
  26. package/dist/es/browser-968d2aed.js +0 -433
  27. package/dist/es/browser-968d2aed.js.map +0 -1
  28. package/dist/es/index-01b23c02.js +0 -10478
  29. package/dist/es/index-01b23c02.js.map +0 -1
  30. package/dist/iife/dialog-embed/browser-4017577e.js +0 -433
  31. package/dist/iife/dialog-embed/browser-4017577e.js.map +0 -1
  32. package/dist/iife/dialog-embed/embed.js +0 -5
  33. package/dist/iife/dialog-embed/embed.js.map +0 -1
  34. package/dist/iife/dialog-embed/index-9204f832.js +0 -32929
  35. package/dist/iife/dialog-embed/index-9204f832.js.map +0 -1
  36. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
  37. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
  38. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +0 -35
  39. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
  40. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
  41. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
  42. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
  43. package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
  44. package/dist/iife/dialog-embed/src/index.d.ts +0 -2
  45. package/dist/iife/dialog-embed/src/utils/env.d.ts +0 -12
  46. package/dist/iife/dialog-embed/src/utils/events.d.ts +0 -2
  47. package/dist/iife/player-embed/browser-279c433a.js +0 -433
  48. package/dist/iife/player-embed/browser-279c433a.js.map +0 -1
  49. package/dist/iife/player-embed/embed.js +0 -5
  50. package/dist/iife/player-embed/embed.js.map +0 -1
  51. package/dist/iife/player-embed/index-525f5a07.js +0 -32486
  52. package/dist/iife/player-embed/index-525f5a07.js.map +0 -1
  53. package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
  54. package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
  55. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +0 -35
  56. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
  57. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
  58. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
  59. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
  60. package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
  61. package/dist/iife/player-embed/src/index.d.ts +0 -2
  62. package/dist/iife/player-embed/src/utils/env.d.ts +0 -12
  63. package/dist/iife/player-embed/src/utils/events.d.ts +0 -2
  64. 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.8b3b1df",
3
+ "version": "0.0.0-experiment.8b8f3c7",
4
4
  "license": "MIT",
5
5
  "author": "Aaron Williams",
6
6
  "main": "dist/es/embeds.js",
@@ -15,6 +15,9 @@
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",
@@ -30,7 +33,8 @@
30
33
  "storybook": "yarn prebuild && storybook dev -p 6007",
31
34
  "prebuild": "yarn build:deps && 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"
34
38
  },
35
39
  "lint-staged": {
36
40
  "**/*.{ts,tsx,js}": "eslint --fix --quiet",
@@ -39,45 +43,46 @@
39
43
  "dependencies": {
40
44
  "@a11y/focus-trap": "^1.0.5",
41
45
  "@lit/task": "^1.0.0",
42
- "@vouchfor/media-player": "0.0.0-experiment.8b3b1df",
46
+ "@vouchfor/canvas-video": "0.0.0-experiment.8b8f3c7",
47
+ "@vouchfor/media-player": "0.0.0-experiment.8b8f3c7",
43
48
  "uuid": "^9.0.1"
44
49
  },
45
50
  "peerDependencies": {
46
- "lit": "^3.1.0"
51
+ "lit": "^3.1.2"
47
52
  },
48
53
  "devDependencies": {
49
54
  "@esm-bundle/chai": "^4.3.4-fix.0",
50
- "@open-wc/testing": "^3.2.0",
51
- "@storybook/addon-essentials": "^7.4.5",
52
- "@storybook/addon-links": "^7.4.5",
53
- "@storybook/blocks": "^7.4.5",
54
- "@storybook/web-components": "^7.4.5",
55
- "@storybook/web-components-vite": "^7.4.5",
56
- "@types/mocha": "^10.0.1",
57
- "@vouchfor/eslint-config": "^1.0.0",
58
- "@vouchfor/prettier-config": "^1.0.0",
59
- "@web/dev-server-esbuild": "^0.4.1",
60
- "@web/test-runner": "^0.17.1",
61
- "@web/test-runner-browserstack": "^0.6.1",
62
- "@web/test-runner-mocha": "^0.8.1",
63
- "@web/test-runner-playwright": "^0.10.1",
64
- "dotenv": "^16.3.1",
65
- "eslint": "^8.50.0",
66
- "eslint-plugin-import": "^2.28.1",
55
+ "@open-wc/testing": "^4.0.0",
56
+ "@storybook/addon-essentials": "^8.0.4",
57
+ "@storybook/addon-links": "^8.0.4",
58
+ "@storybook/blocks": "^8.0.4",
59
+ "@storybook/web-components": "^8.0.4",
60
+ "@storybook/web-components-vite": "^8.0.4",
61
+ "@svgr/core": "^8.1.0",
62
+ "@types/flat": "^5.0.5",
63
+ "@types/mocha": "^10.0.6",
64
+ "@vouchfor/eslint-config": "^1.0.1",
65
+ "@vouchfor/prettier-config": "^1.0.1",
66
+ "@vouchfor/video-utils": "0.0.0-experiment.8b8f3c7",
67
+ "@web/dev-server-esbuild": "^1.0.2",
68
+ "@web/test-runner": "^0.18.1",
69
+ "@web/test-runner-browserstack": "^0.7.1",
70
+ "@web/test-runner-mocha": "^0.9.0",
71
+ "@web/test-runner-playwright": "^0.11.0",
67
72
  "glob": "^10.3.10",
68
- "lint-staged": "^14.0.1",
69
- "lit": "^3.1.0",
73
+ "lint-staged": "^15.2.2",
74
+ "lit": "^3.1.2",
70
75
  "lodash": "^4.17.21",
71
- "prettier": "^3.0.3",
72
76
  "react": "^18.2.0",
73
77
  "react-dom": "^18.2.0",
74
- "rollup-plugin-internal": "^1.0.4",
78
+ "rollup-plugin-tla": "^0.0.2",
75
79
  "sinon": "^17.0.1",
76
- "storybook": "^7.4.5",
77
- "typescript": "^5.1.3",
78
- "vite": "^4.4.9",
79
- "vite-plugin-commonjs": "^0.10.0",
80
- "vite-plugin-dts": "^3.6.0",
81
- "web-component-analyzer": "^1.1.7"
80
+ "storybook": "^8.0.4",
81
+ "svgson": "^5.3.1",
82
+ "typescript": "^5.4.3",
83
+ "vite": "^5.2.2",
84
+ "vite-plugin-commonjs": "^0.10.1",
85
+ "vite-plugin-dts": "^3.7.3",
86
+ "web-component-analyzer": "^2.0.0"
82
87
  }
83
88
  }
@@ -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: absolute;
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.open = !this.open;
34
-
35
- if (this.open) {
36
- if (!this.disableAutoplay && this._mediaPlayerRef?.value) {
37
- this._mediaPlayerRef.value.muted = false;
38
- this._mediaPlayerRef.value.play();
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
- return document.body;
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 };
@@ -58,7 +58,21 @@ const Player: Story = {
58
58
  questions: [],
59
59
  aspectRatio: 0,
60
60
  preload: 'none',
61
- autoplay: false
61
+ autoplay: false,
62
+ controls: [
63
+ 'progress',
64
+ 'play-large',
65
+ 'navigation',
66
+ 'play',
67
+ 'volume',
68
+ 'current-time',
69
+ 'duration',
70
+ 'speed',
71
+ 'captions',
72
+ 'fullscreen',
73
+ 'preview',
74
+ 'languages'
75
+ ]
62
76
  },
63
77
  argTypes: {
64
78
  env: {
@@ -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/media-player';
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';
@@ -1,20 +1,23 @@
1
1
  import { css, html, LitElement } from 'lit';
2
2
  import { customElement, property, state } from 'lit/decorators.js';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { ref } from 'lit/directives/ref.js';
4
+ import { createRef, ref } from 'lit/directives/ref.js';
5
5
 
6
- import type { TemplateInstance } from '@vouchfor/canvas-video';
7
- import type { MediaPlayerProps } from '@vouchfor/media-player';
6
+ import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
7
+ import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
8
+ import type { PropertyValueMap } from 'lit';
8
9
  import type { Environment } from '~/utils/env';
9
10
 
10
11
  import { EventForwardController } from './controllers/event-forwarder';
11
12
  import { FetcherController } from './controllers/fetcher';
12
13
  import { TrackingController } from './controllers/tracking';
13
- import { MediaPlayerProxy } from '~/mixins/media-player-proxy';
14
14
 
15
15
  import '@vouchfor/media-player';
16
16
 
17
- type PlayerEmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'> & {
17
+ type PlayerEmbedProps = Pick<
18
+ MediaPlayerProps,
19
+ 'data' | 'aspectRatio' | 'language' | 'preload' | 'autoplay' | 'controls'
20
+ > & {
18
21
  env: Environment;
19
22
  apiKey: string;
20
23
  disableTracking?: boolean;
@@ -26,7 +29,7 @@ type PlayerEmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload
26
29
  };
27
30
 
28
31
  @customElement('vouch-embed-player')
29
- class PlayerEmbed extends MediaPlayerProxy(LitElement) {
32
+ class PlayerEmbed extends LitElement {
30
33
  static styles = [
31
34
  css`
32
35
  :host {
@@ -49,6 +52,7 @@ class PlayerEmbed extends MediaPlayerProxy(LitElement) {
49
52
  @property({ type: String }) preload: PlayerEmbedProps['preload'] = 'auto';
50
53
  @property({ type: Boolean }) autoplay: PlayerEmbedProps['autoplay'] = false;
51
54
  @property({ type: Number }) aspectRatio: PlayerEmbedProps['aspectRatio'] = 0;
55
+ @property({ type: String }) language?: MediaPlayerProps['language'];
52
56
 
53
57
  private eventController = new EventForwardController(this, [
54
58
  'durationchange',
@@ -61,10 +65,12 @@ class PlayerEmbed extends MediaPlayerProxy(LitElement) {
61
65
  'playing',
62
66
  'ratechange',
63
67
  'scenechange',
68
+ 'scenesupdate',
64
69
  'seeking',
65
70
  'seeked',
66
71
  'timeupdate',
67
72
  'volumechange',
73
+ 'processing',
68
74
  'waiting',
69
75
 
70
76
  'video:loadeddata',
@@ -90,6 +96,108 @@ class PlayerEmbed extends MediaPlayerProxy(LitElement) {
90
96
  return this._fetcherController.fetching;
91
97
  }
92
98
 
99
+ private _mediaPlayerRef = createRef<MediaPlayer>();
100
+
101
+ get waiting() {
102
+ return this._mediaPlayerRef.value?.waiting;
103
+ }
104
+
105
+ get initialised() {
106
+ return this._mediaPlayerRef.value?.initialised;
107
+ }
108
+
109
+ get seeking() {
110
+ return this._mediaPlayerRef.value?.seeking;
111
+ }
112
+
113
+ get paused() {
114
+ return this._mediaPlayerRef.value?.paused;
115
+ }
116
+
117
+ get captions() {
118
+ return this._mediaPlayerRef.value?.captions;
119
+ }
120
+
121
+ get fullscreen() {
122
+ return this._mediaPlayerRef.value?.fullscreen;
123
+ }
124
+
125
+ get duration() {
126
+ return this._mediaPlayerRef.value?.duration;
127
+ }
128
+
129
+ set currentTime(value: number) {
130
+ if (this._mediaPlayerRef.value) {
131
+ this._mediaPlayerRef.value.currentTime = value;
132
+ }
133
+ }
134
+ get currentTime() {
135
+ return this._mediaPlayerRef.value?.currentTime ?? 0;
136
+ }
137
+
138
+ set playbackRate(value: number) {
139
+ if (this._mediaPlayerRef.value) {
140
+ this._mediaPlayerRef.value.playbackRate = value;
141
+ }
142
+ }
143
+ get playbackRate() {
144
+ return this._mediaPlayerRef.value?.playbackRate ?? 1;
145
+ }
146
+
147
+ set volume(value: number) {
148
+ if (this._mediaPlayerRef.value) {
149
+ this._mediaPlayerRef.value.volume = value;
150
+ }
151
+ }
152
+ get volume() {
153
+ return this._mediaPlayerRef.value?.volume ?? 1;
154
+ }
155
+
156
+ set muted(value: boolean) {
157
+ if (this._mediaPlayerRef.value) {
158
+ this._mediaPlayerRef.value.muted = value;
159
+ }
160
+ }
161
+ get muted() {
162
+ return this._mediaPlayerRef.value?.muted ?? false;
163
+ }
164
+
165
+ get scene(): Scene | null {
166
+ return this._mediaPlayerRef.value?.scene ?? null;
167
+ }
168
+
169
+ get scenes(): Scene[] {
170
+ return this._mediaPlayerRef.value?.scenes ?? [];
171
+ }
172
+
173
+ get sceneConfig(): Scenes | null {
174
+ return this._mediaPlayerRef.value?.sceneConfig ?? null;
175
+ }
176
+
177
+ get videoState() {
178
+ return this._mediaPlayerRef.value?.videoState;
179
+ }
180
+
181
+ get mediaPlayer() {
182
+ return this._mediaPlayerRef.value;
183
+ }
184
+
185
+ play() {
186
+ this._mediaPlayerRef.value?.play();
187
+ }
188
+
189
+ pause() {
190
+ this._mediaPlayerRef.value?.pause();
191
+ }
192
+
193
+ reset(time = 0, play = false) {
194
+ this._mediaPlayerRef.value?.reset(time, play);
195
+ }
196
+
197
+ setScene(index: number) {
198
+ this._mediaPlayerRef.value?.setScene(index);
199
+ }
200
+
93
201
  private _renderStyles() {
94
202
  if (!this.aspectRatio) {
95
203
  return html`
@@ -115,6 +223,13 @@ class PlayerEmbed extends MediaPlayerProxy(LitElement) {
115
223
  return null;
116
224
  }
117
225
 
226
+ protected willUpdate(changedProperties: PropertyValueMap<PlayerEmbedProps>) {
227
+ // If the vouch this embed is pointing to changes then reset the player
228
+ if (changedProperties.has('vouchId') && this.vouchId !== changedProperties.get('vouchId')) {
229
+ this.reset(0, false);
230
+ }
231
+ }
232
+
118
233
  render() {
119
234
  return html`
120
235
  ${this._renderStyles()}
@@ -127,6 +242,7 @@ class PlayerEmbed extends MediaPlayerProxy(LitElement) {
127
242
  .template=${this.template}
128
243
  aspectRatio=${ifDefined(this.aspectRatio)}
129
244
  preload=${ifDefined(this.preload)}
245
+ language=${ifDefined(this.language)}
130
246
  .controls=${this.controls}
131
247
  ></vmp-media-player>
132
248
  `;
@@ -28,7 +28,7 @@ function playerLoaded(player: PlayerEmbed) {
28
28
  }
29
29
 
30
30
  describe('Embeds', () => {
31
- it('passes', async () => {
31
+ it('Sends correct tracking events', async () => {
32
32
  const player = await fixture<PlayerEmbed>(
33
33
  html`<vouch-embed-player env="dev" .data=${data} aspectratio=${1}></vouch-embed-player>`
34
34
  );
@@ -1,4 +1,4 @@
1
- import type { Vouch } from '@vouchfor/media-player';
1
+ import type { Vouch } from '@vouchfor/video-utils';
2
2
 
3
3
  /* eslint-disable max-lines */
4
4
  const data = {
@@ -39,14 +39,14 @@ const data = {
39
39
  thumbnail:
40
40
  'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/5c66bb3a-ed68-41a0-a601-a49865104418/5c66bb3a-ed68-41a0-a601-a49865104418_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
41
41
  },
42
- client: {
43
- id: '03540d70-1c75-4867-a235-bac842ed6ce4',
44
- name: 'Not Supplied',
45
- logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
46
- },
47
42
  contact: {
48
43
  id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
49
- name: 'Aaron Williams'
44
+ name: 'Aaron Williams',
45
+ client: {
46
+ id: '03540d70-1c75-4867-a235-bac842ed6ce4',
47
+ name: 'Not Supplied',
48
+ logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
49
+ }
50
50
  },
51
51
  captions: {
52
52
  current:
@@ -83,14 +83,14 @@ const data = {
83
83
  thumbnail:
84
84
  'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/5c66bb3a-ed68-41a0-a601-a49865104418/5c66bb3a-ed68-41a0-a601-a49865104418_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
85
85
  },
86
- client: {
87
- id: '03540d70-1c75-4867-a235-bac842ed6ce4',
88
- logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
89
- },
90
86
  contact: {
91
87
  id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
92
88
  name: 'Aaron Williams',
93
- roleTitle: 'Software Engineer'
89
+ roleTitle: 'Software Engineer',
90
+ client: {
91
+ id: '03540d70-1c75-4867-a235-bac842ed6ce4',
92
+ logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
93
+ }
94
94
  },
95
95
  captions: {
96
96
  current:
@@ -121,15 +121,15 @@ const data = {
121
121
  thumbnail:
122
122
  'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/e77c81a7-f6ef-4eae-91fc-b620d092d8d6/e77c81a7-f6ef-4eae-91fc-b620d092d8d6_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
123
123
  },
124
- client: {
125
- id: '03540d70-1c75-4867-a235-bac842ed6ce4',
126
- name: 'Vouch',
127
- logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
128
- },
129
124
  contact: {
130
125
  id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
131
126
  name: 'Aaron Williams',
132
- roleTitle: 'Software Engineer'
127
+ roleTitle: 'Software Engineer',
128
+ client: {
129
+ id: '03540d70-1c75-4867-a235-bac842ed6ce4',
130
+ name: 'Vouch',
131
+ logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
132
+ }
133
133
  },
134
134
  captions: {
135
135
  current:
@@ -160,15 +160,15 @@ const data = {
160
160
  thumbnail:
161
161
  'https://d2rxhdlm2q91uk.cloudfront.net/TVik9uTMgE/6JQEIPeStt/39fd188d-a4dc-43b9-bac8-32fd71bfbc90/39fd188d-a4dc-43b9-bac8-32fd71bfbc90_poster.0000001.jpg?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kMnJ4aGRsbTJxOTF1ay5jbG91ZGZyb250Lm5ldC9UVmlrOXVUTWdFLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjIwMTYzMjM0Mjl9fX1dfQ__&Key-Pair-Id=K2SWKOH0FA5F6M&Signature=SGA54MFpy4jaqKJHKEuxRfjk-~NBFAh1tdW9Y6uYJwc0LFjDDgX1sraerSyohmVhj~-QVIrglY5BvglDIhrFcLJWGTkgj4vhyLprk1a7EDckv0HBgp-k1ZKvoDtt3wBOzrL4GicfXBkuMpIu5jv5MY3xemlJj2a6V~h65XJuLO4u-xS~McH6rS3mRxoNl4GcYUVm4upre1DGQx-5Suy6Ateoxl6xxoF8kg5EL02KxkIGiRpwXJTvVmUuVF0rpBj-IE40MfmhLBQ1NNSXiqb3-HjpkKwhYPvB5APVh23mzGmqJ0P3jbr2F1cU4Jvlqsjb6GVP61wGOz9ITeWPZkOy8A__'
162
162
  },
163
- client: {
164
- id: '03540d70-1c75-4867-a235-bac842ed6ce4',
165
- name: 'Vouch',
166
- logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
167
- },
168
163
  contact: {
169
164
  id: 'b62f62a3-0cd4-4512-9b52-121cb2f3e72f',
170
165
  name: 'Aaron Williams',
171
- roleTitle: 'Software Engineer'
166
+ roleTitle: 'Software Engineer',
167
+ client: {
168
+ id: '03540d70-1c75-4867-a235-bac842ed6ce4',
169
+ name: 'Vouch',
170
+ logoSrc: 'https://logo.clearbit.com/vouchfor.com?size=260'
171
+ }
172
172
  },
173
173
  captions: {
174
174
  current: