@vouchfor/embeds 0.0.0-experiment.9821b79 → 0.0.0-experiment.98c50ae
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 +1151 -7
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
- package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
- package/dist/es/src/components/DialogEmbed/index.d.ts +38 -0
- package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/es/src/components/{Embed → PlayerEmbed}/controllers/fetcher.d.ts +4 -4
- package/dist/es/src/components/{Embed → PlayerEmbed}/controllers/tracking/index.d.ts +4 -4
- package/dist/es/src/components/{Embed → PlayerEmbed}/controllers/tracking/utils.d.ts +1 -1
- package/dist/es/src/components/{Embed → PlayerEmbed}/index.d.ts +28 -22
- package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +4 -0
- package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
- package/dist/es/src/index.d.ts +2 -1
- package/dist/iife/dialog-embed/embed.iife.js +1757 -0
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
- package/dist/iife/embeds.iife.js +566 -381
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +1619 -0
- package/dist/iife/player-embed/embed.iife.js.map +1 -0
- package/package.json +42 -32
- package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
- package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
- package/src/components/DialogEmbed/DialogPortal.ts +126 -0
- package/src/components/DialogEmbed/index.ts +97 -0
- package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
- package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +29 -15
- package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
- package/src/components/{Embed → PlayerEmbed}/controllers/fetcher.ts +11 -11
- package/src/components/{Embed → PlayerEmbed}/controllers/tracking/index.ts +4 -4
- package/src/components/{Embed → PlayerEmbed}/controllers/tracking/utils.ts +2 -2
- package/src/components/{Embed → PlayerEmbed}/index.ts +45 -23
- package/src/components/{Embed/tests/Embed.spec.ts → PlayerEmbed/tests/PlayerEmbed.spec.ts} +13 -4
- package/src/components/PlayerEmbed/tests/data.ts +227 -0
- package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
- package/src/index.ts +2 -1
- package/dist/es/browser-8d4ae80d.js +0 -433
- package/dist/es/browser-8d4ae80d.js.map +0 -1
- package/dist/es/index-74d4cefa.js +0 -9980
- package/dist/es/index-74d4cefa.js.map +0 -1
- package/dist/es/src/components/Embed/tests/data.d.ts +0 -3
- package/src/components/Embed/tests/data.ts +0 -183
@@ -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 };
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import { html } from 'lit';
|
2
2
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
3
3
|
|
4
|
-
import type {
|
4
|
+
import type { PlayerEmbedProps } from '.';
|
5
5
|
import type { Meta, StoryObj } from '@storybook/web-components';
|
6
6
|
|
7
|
-
import '
|
7
|
+
import '.';
|
8
8
|
|
9
|
-
type
|
9
|
+
type PlayerEmbedArgs = PlayerEmbedProps & {
|
10
10
|
showVouch?: boolean;
|
11
11
|
};
|
12
12
|
|
13
|
-
const
|
13
|
+
const _PlayerEmbed = ({
|
14
14
|
vouchId,
|
15
15
|
templateId,
|
16
16
|
questions,
|
@@ -20,10 +20,10 @@ const _Embed = ({
|
|
20
20
|
apiKey,
|
21
21
|
controls,
|
22
22
|
aspectRatio
|
23
|
-
}:
|
23
|
+
}: PlayerEmbedArgs) => {
|
24
24
|
return html`
|
25
25
|
<div style="height: 100vh">
|
26
|
-
<vouch-embed
|
26
|
+
<vouch-embed-player
|
27
27
|
env=${ifDefined(env)}
|
28
28
|
apiKey=${ifDefined(apiKey)}
|
29
29
|
vouchId=${ifDefined(vouchId)}
|
@@ -34,22 +34,22 @@ const _Embed = ({
|
|
34
34
|
preload=${ifDefined(preload)}
|
35
35
|
aspectRatio=${ifDefined(aspectRatio)}
|
36
36
|
@error=${console.log}
|
37
|
-
></vouch-embed>
|
37
|
+
></vouch-embed-player>
|
38
38
|
</div>
|
39
39
|
`;
|
40
40
|
};
|
41
41
|
|
42
42
|
// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction
|
43
43
|
const meta = {
|
44
|
-
title: '
|
44
|
+
title: 'Embeds',
|
45
45
|
tags: ['autodocs'],
|
46
|
-
render: (args) =>
|
47
|
-
component: 'vouch-embed'
|
48
|
-
} satisfies Meta<
|
46
|
+
render: (args) => _PlayerEmbed(args),
|
47
|
+
component: 'vouch-embed-player'
|
48
|
+
} satisfies Meta<PlayerEmbedProps>;
|
49
49
|
|
50
|
-
type Story = StoryObj<
|
50
|
+
type Story = StoryObj<PlayerEmbedArgs>;
|
51
51
|
|
52
|
-
const
|
52
|
+
const Player: Story = {
|
53
53
|
args: {
|
54
54
|
env: 'dev',
|
55
55
|
apiKey: 'TVik9uTMgE-PD25UTHIS6gyl0hMBWC7AT4dkpdlLBT4VIfDWZJrQiCk6Ak7m1',
|
@@ -58,7 +58,21 @@ const Embed: 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: {
|
@@ -76,4 +90,4 @@ const Embed: Story = {
|
|
76
90
|
};
|
77
91
|
|
78
92
|
export default meta;
|
79
|
-
export {
|
93
|
+
export { Player };
|
@@ -1,27 +1,28 @@
|
|
1
1
|
import { createRef, ref } from 'lit/directives/ref.js';
|
2
2
|
|
3
|
-
import type {
|
3
|
+
import type { PlayerEmbed } from '..';
|
4
4
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
5
|
+
import type { DirectiveResult } from 'lit/directive.js';
|
5
6
|
import type { Ref } from 'lit/directives/ref.js';
|
6
7
|
|
7
8
|
import { forwardEvent } from '~/utils/events';
|
8
9
|
|
9
|
-
type
|
10
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
10
11
|
|
11
12
|
class EventForwardController implements ReactiveController {
|
12
|
-
host:
|
13
|
+
host: PlayerEmbedHost;
|
13
14
|
|
14
15
|
private _events: string[] = [];
|
15
16
|
private _cleanup: (() => void)[] = [];
|
16
17
|
private _forwardElementRef: Ref<HTMLElement> = createRef();
|
17
18
|
|
18
|
-
constructor(host:
|
19
|
+
constructor(host: PlayerEmbedHost, events: string[]) {
|
19
20
|
this.host = host;
|
20
21
|
this._events = events;
|
21
22
|
host.addController(this);
|
22
23
|
}
|
23
24
|
|
24
|
-
register() {
|
25
|
+
register(): DirectiveResult {
|
25
26
|
return ref(this._forwardElementRef);
|
26
27
|
}
|
27
28
|
|
@@ -1,29 +1,29 @@
|
|
1
1
|
import { Task } from '@lit/task';
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
3
3
|
|
4
|
-
import type {
|
4
|
+
import type { PlayerEmbed, PlayerEmbedProps } from '..';
|
5
5
|
import type { ReactiveControllerHost } from 'lit';
|
6
6
|
import type { Environment } from '~/utils/env';
|
7
7
|
|
8
8
|
import { getEnvUrls } from '~/utils/env';
|
9
9
|
|
10
|
-
type
|
10
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
11
11
|
|
12
12
|
type FetchTaskDeps = [
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
PlayerEmbedProps['env'],
|
14
|
+
PlayerEmbedProps['apiKey'],
|
15
|
+
PlayerEmbedProps['data'],
|
16
|
+
PlayerEmbedProps['vouchId'],
|
17
|
+
PlayerEmbedProps['templateId']
|
18
18
|
];
|
19
19
|
|
20
|
-
type FilterTaskDeps = [
|
20
|
+
type FilterTaskDeps = [PlayerEmbedProps['data'], PlayerEmbedProps['questions']];
|
21
21
|
|
22
22
|
class FetcherController {
|
23
|
-
host:
|
23
|
+
host: PlayerEmbedHost;
|
24
24
|
|
25
25
|
private _fetching = false;
|
26
|
-
private _vouch:
|
26
|
+
private _vouch: PlayerEmbedProps['data'];
|
27
27
|
|
28
28
|
set fetching(value) {
|
29
29
|
if (this._fetching !== value) {
|
@@ -97,7 +97,7 @@ class FetcherController {
|
|
97
97
|
return template;
|
98
98
|
};
|
99
99
|
|
100
|
-
constructor(host:
|
100
|
+
constructor(host: PlayerEmbedHost) {
|
101
101
|
this.host = host;
|
102
102
|
new Task<FetchTaskDeps, void>(
|
103
103
|
this.host,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { PlayerEmbed } from '../..';
|
2
2
|
import type { VideoEventDetail } from '@vouchfor/media-player';
|
3
3
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
4
4
|
|
@@ -7,7 +7,7 @@ import { getEnvUrls } from '~/utils/env';
|
|
7
7
|
|
8
8
|
const MINIMUM_SEND_THRESHOLD = 1;
|
9
9
|
|
10
|
-
type
|
10
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
11
11
|
|
12
12
|
type TrackingEvent = 'VOUCH_LOADED' | 'VOUCH_RESPONSE_VIEWED' | 'VIDEO_PLAYED' | 'VIDEO_STREAMED';
|
13
13
|
type TrackingPayload = {
|
@@ -33,7 +33,7 @@ type BooleanMap = {
|
|
33
33
|
};
|
34
34
|
|
35
35
|
class TrackingController implements ReactiveController {
|
36
|
-
host:
|
36
|
+
host: PlayerEmbedHost;
|
37
37
|
|
38
38
|
private _batchedEvents: BatchEvent[] = [];
|
39
39
|
private _hasPlayed = false;
|
@@ -43,7 +43,7 @@ class TrackingController implements ReactiveController {
|
|
43
43
|
private _streamLatestTime: TimeMap = {};
|
44
44
|
private _currentlyPlayingVideo: VideoEventDetail | null = null;
|
45
45
|
|
46
|
-
constructor(host:
|
46
|
+
constructor(host: PlayerEmbedHost) {
|
47
47
|
this.host = host;
|
48
48
|
host.addController(this);
|
49
49
|
}
|
@@ -2,10 +2,10 @@ 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
|
-
import packageJson from '
|
8
|
+
import packageJson from '~/../package.json';
|
9
9
|
import { getEnvUrls } from '~/utils/env';
|
10
10
|
|
11
11
|
function createVisitor(env: Environment) {
|
@@ -5,7 +5,7 @@ import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
5
|
|
6
6
|
import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
|
7
7
|
import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
|
8
|
-
import type {
|
8
|
+
import type { PropertyValueMap } from 'lit';
|
9
9
|
import type { Environment } from '~/utils/env';
|
10
10
|
|
11
11
|
import { EventForwardController } from './controllers/event-forwarder';
|
@@ -14,7 +14,10 @@ import { TrackingController } from './controllers/tracking';
|
|
14
14
|
|
15
15
|
import '@vouchfor/media-player';
|
16
16
|
|
17
|
-
type
|
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;
|
@@ -25,8 +28,8 @@ type EmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'a
|
|
25
28
|
questions?: number[];
|
26
29
|
};
|
27
30
|
|
28
|
-
@customElement('vouch-embed')
|
29
|
-
class
|
31
|
+
@customElement('vouch-embed-player')
|
32
|
+
class PlayerEmbed extends LitElement {
|
30
33
|
static styles = [
|
31
34
|
css`
|
32
35
|
:host {
|
@@ -35,22 +38,21 @@ class Embed extends LitElement {
|
|
35
38
|
`
|
36
39
|
];
|
37
40
|
|
38
|
-
|
41
|
+
@property({ type: Object }) data: PlayerEmbedProps['data'];
|
42
|
+
@property({ type: String }) vouchId: PlayerEmbedProps['vouchId'];
|
43
|
+
@property({ type: String }) templateId: PlayerEmbedProps['templateId'];
|
44
|
+
@property({ type: Array }) questions: PlayerEmbedProps['questions'];
|
39
45
|
|
40
|
-
@property({ type:
|
41
|
-
@property({ type: String })
|
42
|
-
@property({ type:
|
43
|
-
@property({ type:
|
46
|
+
@property({ type: String }) env: PlayerEmbedProps['env'] = 'prod';
|
47
|
+
@property({ type: String }) apiKey: PlayerEmbedProps['apiKey'] = '';
|
48
|
+
@property({ type: Boolean }) disableTracking: PlayerEmbedProps['disableTracking'] = false;
|
49
|
+
@property({ type: String }) trackingSource: PlayerEmbedProps['trackingSource'] = 'embedded_player';
|
44
50
|
|
45
|
-
@property({ type:
|
46
|
-
@property({ type: String })
|
47
|
-
@property({ type: Boolean })
|
48
|
-
@property({ type:
|
49
|
-
|
50
|
-
@property({ type: Array }) controls: EmbedProps['controls'];
|
51
|
-
@property({ type: String }) preload: EmbedProps['preload'] = 'auto';
|
52
|
-
@property({ type: Boolean }) autoplay: EmbedProps['autoplay'] = false;
|
53
|
-
@property({ type: Number }) aspectRatio: EmbedProps['aspectRatio'] = 0;
|
51
|
+
@property({ type: Array }) controls: PlayerEmbedProps['controls'];
|
52
|
+
@property({ type: String }) preload: PlayerEmbedProps['preload'] = 'auto';
|
53
|
+
@property({ type: Boolean }) autoplay: PlayerEmbedProps['autoplay'] = false;
|
54
|
+
@property({ type: Number }) aspectRatio: PlayerEmbedProps['aspectRatio'] = 0;
|
55
|
+
@property({ type: String }) language?: MediaPlayerProps['language'];
|
54
56
|
|
55
57
|
private eventController = new EventForwardController(this, [
|
56
58
|
'durationchange',
|
@@ -63,10 +65,12 @@ class Embed extends LitElement {
|
|
63
65
|
'playing',
|
64
66
|
'ratechange',
|
65
67
|
'scenechange',
|
68
|
+
'scenesupdate',
|
66
69
|
'seeking',
|
67
70
|
'seeked',
|
68
71
|
'timeupdate',
|
69
72
|
'volumechange',
|
73
|
+
'processing',
|
70
74
|
'waiting',
|
71
75
|
|
72
76
|
'video:loadeddata',
|
@@ -85,17 +89,23 @@ class Embed extends LitElement {
|
|
85
89
|
// @ts-ignore
|
86
90
|
private _trackingController = new TrackingController(this);
|
87
91
|
|
88
|
-
@state() vouch:
|
92
|
+
@state() vouch: PlayerEmbedProps['data'];
|
89
93
|
@state() template: TemplateInstance | undefined;
|
90
94
|
|
91
95
|
get fetching() {
|
92
96
|
return this._fetcherController.fetching;
|
93
97
|
}
|
94
98
|
|
99
|
+
private _mediaPlayerRef = createRef<MediaPlayer>();
|
100
|
+
|
95
101
|
get waiting() {
|
96
102
|
return this._mediaPlayerRef.value?.waiting;
|
97
103
|
}
|
98
104
|
|
105
|
+
get initialised() {
|
106
|
+
return this._mediaPlayerRef.value?.initialised;
|
107
|
+
}
|
108
|
+
|
99
109
|
get seeking() {
|
100
110
|
return this._mediaPlayerRef.value?.seeking;
|
101
111
|
}
|
@@ -180,6 +190,10 @@ class Embed extends LitElement {
|
|
180
190
|
this._mediaPlayerRef.value?.pause();
|
181
191
|
}
|
182
192
|
|
193
|
+
reset(time = 0, play = false) {
|
194
|
+
this._mediaPlayerRef.value?.reset(time, play);
|
195
|
+
}
|
196
|
+
|
183
197
|
setScene(index: number) {
|
184
198
|
this._mediaPlayerRef.value?.setScene(index);
|
185
199
|
}
|
@@ -209,6 +223,13 @@ class Embed extends LitElement {
|
|
209
223
|
return null;
|
210
224
|
}
|
211
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
|
+
|
212
233
|
render() {
|
213
234
|
return html`
|
214
235
|
${this._renderStyles()}
|
@@ -221,6 +242,7 @@ class Embed extends LitElement {
|
|
221
242
|
.template=${this.template}
|
222
243
|
aspectRatio=${ifDefined(this.aspectRatio)}
|
223
244
|
preload=${ifDefined(this.preload)}
|
245
|
+
language=${ifDefined(this.language)}
|
224
246
|
.controls=${this.controls}
|
225
247
|
></vmp-media-player>
|
226
248
|
`;
|
@@ -229,15 +251,15 @@ class Embed extends LitElement {
|
|
229
251
|
|
230
252
|
declare global {
|
231
253
|
interface HTMLElementTagNameMap {
|
232
|
-
'vouch-embed':
|
254
|
+
'vouch-embed-player': PlayerEmbed;
|
233
255
|
}
|
234
256
|
|
235
257
|
namespace JSX {
|
236
258
|
interface IntrinsicElements {
|
237
|
-
'vouch-embed':
|
259
|
+
'vouch-embed-player': PlayerEmbed;
|
238
260
|
}
|
239
261
|
}
|
240
262
|
}
|
241
263
|
|
242
|
-
export {
|
243
|
-
export type {
|
264
|
+
export { PlayerEmbed };
|
265
|
+
export type { PlayerEmbedProps };
|
@@ -3,7 +3,7 @@ import { expect, fixture, waitUntil } from '@open-wc/testing';
|
|
3
3
|
import { html } from 'lit';
|
4
4
|
import sinon from 'sinon';
|
5
5
|
|
6
|
-
import type {
|
6
|
+
import type { PlayerEmbed } from '../index.js';
|
7
7
|
import type { VideoMap } from '@vouchfor/media-player';
|
8
8
|
|
9
9
|
import { data } from './data.js';
|
@@ -17,7 +17,7 @@ function getVideo(videos: VideoMap) {
|
|
17
17
|
return Object.values(videos)[0];
|
18
18
|
}
|
19
19
|
|
20
|
-
function playerLoaded(player:
|
20
|
+
function playerLoaded(player: PlayerEmbed) {
|
21
21
|
return waitUntil(
|
22
22
|
() => {
|
23
23
|
return player.mediaPlayer?.initialised;
|
@@ -28,8 +28,10 @@ function playerLoaded(player: Embed) {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
describe('Embeds', () => {
|
31
|
-
it('
|
32
|
-
const player = await fixture<
|
31
|
+
it('Sends correct tracking events', async () => {
|
32
|
+
const player = await fixture<PlayerEmbed>(
|
33
|
+
html`<vouch-embed-player env="dev" .data=${data} aspectratio=${1}></vouch-embed-player>`
|
34
|
+
);
|
33
35
|
// @ts-ignore - accessing private property
|
34
36
|
const sendTrackingSpy = sinon.spy(player._trackingController, '_sendTrackingEvent');
|
35
37
|
// @ts-ignore - accessing private property
|
@@ -54,6 +56,13 @@ describe('Embeds', () => {
|
|
54
56
|
expect(sendTrackingSpy.callCount).to.be.eq(0);
|
55
57
|
// Destroy node because events are sent when node is removed from the document
|
56
58
|
player.remove();
|
59
|
+
await waitUntil(
|
60
|
+
() => {
|
61
|
+
return createTrackingSpy.args[2];
|
62
|
+
},
|
63
|
+
'Cleanup event has not fired',
|
64
|
+
{ timeout: 5000 }
|
65
|
+
);
|
57
66
|
expect(sendTrackingSpy.callCount).to.be.eq(1);
|
58
67
|
expect(createTrackingSpy.args[0]).to.eql([
|
59
68
|
'VIDEO_PLAYED',
|