forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
42 lines (36 loc) · 1.18 KB
/
Copy pathconfig.ts
File metadata and controls
42 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { MediaEventType } from '@snowplow/browser-plugin-media';
import { CommonMediaEventProperties, MediaTrackingConfiguration } from '@snowplow/browser-plugin-media/src/types';
export type HTML5MediaEventTypes = Extract<
MediaEventType,
| MediaEventType.Ready
| MediaEventType.Play
| MediaEventType.Pause
| MediaEventType.End
| MediaEventType.SeekEnd
| MediaEventType.PlaybackRateChange
| MediaEventType.VolumeChange
| MediaEventType.FullscreenChange
| MediaEventType.PictureInPictureChange
| MediaEventType.BufferStart
| MediaEventType.BufferEnd
| MediaEventType.Error
| MediaEventType.Ping
| MediaEventType.PercentProgress
>;
export type Config = {
video: string | HTMLMediaElement;
label?: string;
} & CommonMediaEventProperties &
Omit<MediaTrackingConfiguration, 'player'>;
export interface StringConfig extends Config {
video: string;
}
export function isStringConfig(config: Config): config is StringConfig {
return typeof config.video === 'string';
}
export interface ElementConfig extends Config {
video: HTMLMediaElement;
}
export function isElementConfig(config: Config): config is ElementConfig {
return config.video instanceof HTMLMediaElement;
}