@vindral/web-sdk 3.4.3 → 4.0.0
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/B7jz034g.js +147 -0
- package/BTxJOjm9.js +32 -0
- package/BzSm3HsC.js +312 -0
- package/C291RiDK.js +127 -0
- package/DwDXQwR0.js +6037 -0
- package/README.md +74 -30
- package/api-client.d.ts +151 -0
- package/api-client.js +4 -0
- package/cast-sender.d.ts +396 -0
- package/cast-sender.js +230 -0
- package/core.d.ts +1364 -0
- package/core.js +14 -0
- package/{index.d.ts → legacy.d.ts} +222 -216
- package/legacy.es.js +7724 -0
- package/legacy.umd.js +59 -0
- package/package.json +25 -9
- package/player.d.ts +1583 -0
- package/player.js +3310 -0
- package/style.css +1 -1
- package/vindral-player-component.js +2 -0
- package/index.js +0 -7674
- package/index.umd.cjs +0 -59
package/README.md
CHANGED
|
@@ -30,13 +30,13 @@ Add the following HTML snippet, set `channelId` to channel id credential, and do
|
|
|
30
30
|
|
|
31
31
|
```html
|
|
32
32
|
<iframe
|
|
33
|
-
src="https://
|
|
33
|
+
src="https://player.vindral.com/?channelId=vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f"
|
|
34
34
|
frameborder="0"
|
|
35
35
|
allowfullscreen
|
|
36
36
|
></iframe>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
[See the player in action](https://
|
|
39
|
+
[See the player in action](https://player.vindral.com/?channelId=vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f) or [read more about Embed Player here](https://docs.vindral.com/playout/embeddable-player).
|
|
40
40
|
|
|
41
41
|
## Installation
|
|
42
42
|
|
|
@@ -52,52 +52,47 @@ or `yarn`:
|
|
|
52
52
|
yarn add @vindral/web-sdk
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
### Player
|
|
55
|
+
### Vindral Player
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Vindral Player is our ready-to-go web component-based player for easy integration into your web applications. It is ideal for customizing controls or when the embed solution is not sufficient.
|
|
58
58
|
|
|
59
59
|
**Example**
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
The example assumes that there is an HTML page that loads this script that has at least a div with `id="#root"`.
|
|
61
|
+
To be able to use the `<vindral-player />` in your HTML you have to call `registerComponents`.
|
|
64
62
|
|
|
65
63
|
```javascript
|
|
66
|
-
import {
|
|
67
|
-
|
|
68
|
-
const root = document.querySelector("#root")
|
|
69
|
-
|
|
70
|
-
const player = new Player({
|
|
71
|
-
url: "https://lb.cdn.vindral.com",
|
|
72
|
-
channelId: "vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f",
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// Starts playback
|
|
76
|
-
player.core.play()
|
|
64
|
+
import { registerComponents } from "@vindral/web-sdk/player"
|
|
77
65
|
|
|
78
|
-
|
|
79
|
-
player.attach(root)
|
|
66
|
+
registerComponents()
|
|
80
67
|
```
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
Or use vindral-player-component.js is a self-registering variant of the web components player intended to be used from a script tag.
|
|
83
70
|
|
|
84
|
-
```
|
|
85
|
-
|
|
71
|
+
```html
|
|
72
|
+
<script type="module" async src="https://cdn.jsdelivr.net/npm/@vindral/web-sdk/vindral-player-component.js"></script>
|
|
86
73
|
```
|
|
87
74
|
|
|
88
|
-
|
|
75
|
+
Channel id is the only required attribute when using `<vindral-player />`.
|
|
89
76
|
|
|
90
|
-
```
|
|
91
|
-
|
|
77
|
+
```html
|
|
78
|
+
<vindral-player channelId="vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f"></vindral-player>
|
|
92
79
|
```
|
|
93
80
|
|
|
94
|
-
|
|
81
|
+
Easy to customize controls with CSS variables.
|
|
95
82
|
|
|
96
|
-
```
|
|
97
|
-
<
|
|
83
|
+
```css
|
|
84
|
+
<style>
|
|
85
|
+
vindral-player {
|
|
86
|
+
aspect-ratio: 16 / 9;
|
|
87
|
+
--vindral-fg-strong: pink;
|
|
88
|
+
--vindral-mute-button-display: none;
|
|
89
|
+
--vindral-pip-button-display: none;
|
|
90
|
+
--vindral-fullscreen-button-display: none;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
98
93
|
```
|
|
99
94
|
|
|
100
|
-
|
|
95
|
+
[Read the full API reference for all the attributes and CSS variables](https://docs.vindral.com/web-sdk/player)
|
|
101
96
|
|
|
102
97
|
### Core SDK
|
|
103
98
|
|
|
@@ -167,6 +162,55 @@ button.addEventListener("click", () => {
|
|
|
167
162
|
})
|
|
168
163
|
```
|
|
169
164
|
|
|
165
|
+
### Player SDK
|
|
166
|
+
|
|
167
|
+
> **Deprecated**: The Player SDK is deprecated and has been replaced with the [Vindral Player](#vindral-player). It can still be used with `@vindral/web-sdk/legacy`.
|
|
168
|
+
|
|
169
|
+
The Player SDK provides a ready-to-go player with controls - perfect for use cases where the embed solution is not enough, such as when access to the javascript API is needed.
|
|
170
|
+
|
|
171
|
+
**Example**
|
|
172
|
+
|
|
173
|
+
This example attaches a player to an element with the id `#root`. The player will take care of activating audio when needed and provides a minimalistic UI for fullscreen, channel switching, language selection, etc.
|
|
174
|
+
|
|
175
|
+
The example assumes that there is an HTML page that loads this script that has at least a div with `id="#root"`.
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
import { Player } from "@vindral/web-sdk/legacy"
|
|
179
|
+
|
|
180
|
+
const root = document.querySelector("#root")
|
|
181
|
+
|
|
182
|
+
const player = new Player({
|
|
183
|
+
url: "https://lb.cdn.vindral.com",
|
|
184
|
+
channelId: "vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f",
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
// Starts playback
|
|
188
|
+
player.core.play()
|
|
189
|
+
|
|
190
|
+
// Attaches the player view to the DOM
|
|
191
|
+
player.attach(root)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Finally, import `@vindral/web-sdk/style.css` (or `./node_modules/@vindral/web-sdk/style.css` if that doesn't work) into your CSS. This step may differ depending on your build tools, some tools will allow you to import CSS directly in your js:
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
import "@vindral/web-sdk/style.css"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
or, from a CSS file:
|
|
201
|
+
|
|
202
|
+
```css
|
|
203
|
+
@import "@vindral/web-sdk/style.css";
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
or, in your html file:
|
|
207
|
+
|
|
208
|
+
```html
|
|
209
|
+
<link rel="stylesheet" href="./node_modules/@vindral/web-sdk/style.css" />
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
We recommend that you consult the documentation for your build tool for more information.
|
|
213
|
+
|
|
170
214
|
#### License and support
|
|
171
215
|
|
|
172
216
|
Vindral is a commercial product and requires an active, paid license to access and use. To obtain such a license, or in case you have any questions, do not hesitate to [get in touch](https://vindral.com/inquiries)!
|
package/api-client.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
type AudioCodec = "aac" | "opus" | "mp3";
|
|
2
|
+
type VideoCodec = "h264" | "av1";
|
|
3
|
+
interface RenditionProps {
|
|
4
|
+
id: number;
|
|
5
|
+
bitRate: number;
|
|
6
|
+
codecString?: string;
|
|
7
|
+
language?: string;
|
|
8
|
+
meta?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
interface VideoRenditionProps {
|
|
11
|
+
codec: VideoCodec;
|
|
12
|
+
frameRate: [
|
|
13
|
+
number,
|
|
14
|
+
number
|
|
15
|
+
];
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
interface AudioRenditionProps {
|
|
20
|
+
codec: AudioCodec;
|
|
21
|
+
channels: number;
|
|
22
|
+
sampleRate: number;
|
|
23
|
+
}
|
|
24
|
+
interface TextRenditionProps {
|
|
25
|
+
codec: "webvtt";
|
|
26
|
+
kind: "subtitles" | "captions";
|
|
27
|
+
label?: string;
|
|
28
|
+
}
|
|
29
|
+
type VideoRendition = VideoRenditionProps & RenditionProps;
|
|
30
|
+
type AudioRendition = AudioRenditionProps & RenditionProps;
|
|
31
|
+
type TextRendition = TextRenditionProps & RenditionProps;
|
|
32
|
+
type Rendition = VideoRendition | AudioRendition | TextRendition;
|
|
33
|
+
/**
|
|
34
|
+
* Channel
|
|
35
|
+
*/
|
|
36
|
+
export interface Channel {
|
|
37
|
+
/**
|
|
38
|
+
* Channel ID for the channel
|
|
39
|
+
*/
|
|
40
|
+
channelId: string;
|
|
41
|
+
/**
|
|
42
|
+
* Display name
|
|
43
|
+
*/
|
|
44
|
+
name: string;
|
|
45
|
+
/**
|
|
46
|
+
* Indicates whether there is an incoming source feed for the channel
|
|
47
|
+
*/
|
|
48
|
+
isLive: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* URLs to fetch thumbnail from
|
|
51
|
+
*/
|
|
52
|
+
thumbnailUrls: string[];
|
|
53
|
+
}
|
|
54
|
+
interface ClientOverrides {
|
|
55
|
+
maxVideoBitRate?: number;
|
|
56
|
+
minBufferTime?: number;
|
|
57
|
+
maxBufferTime?: number;
|
|
58
|
+
burstEnabled?: boolean;
|
|
59
|
+
sizeBasedResolutionCapEnabled?: boolean;
|
|
60
|
+
separateVideoSocketEnabled?: boolean;
|
|
61
|
+
videoCodecs?: string[];
|
|
62
|
+
}
|
|
63
|
+
interface ChannelWithRenditionsAndOverrides extends Channel {
|
|
64
|
+
renditions: Rendition[];
|
|
65
|
+
overrides?: ClientOverrides;
|
|
66
|
+
}
|
|
67
|
+
interface ConnectOptions {
|
|
68
|
+
channelGroupId?: string;
|
|
69
|
+
channelId: string;
|
|
70
|
+
}
|
|
71
|
+
interface Telemetry {
|
|
72
|
+
url: string;
|
|
73
|
+
probability?: number;
|
|
74
|
+
includeErrors?: boolean;
|
|
75
|
+
includeEvents?: boolean;
|
|
76
|
+
includeStats?: boolean;
|
|
77
|
+
maxRetries?: number;
|
|
78
|
+
maxErrorReports?: number;
|
|
79
|
+
interval?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface ConnectResponse {
|
|
82
|
+
logsUrl?: string;
|
|
83
|
+
statsUrl?: string;
|
|
84
|
+
telemetry?: Telemetry;
|
|
85
|
+
channels: ChannelWithRenditionsAndOverrides[];
|
|
86
|
+
edges: string[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ApiClientOptions
|
|
90
|
+
*/
|
|
91
|
+
export interface ApiClientOptions {
|
|
92
|
+
/**
|
|
93
|
+
* String representing the URL to the public CDN API.
|
|
94
|
+
*/
|
|
95
|
+
publicEndpoint: string;
|
|
96
|
+
/**
|
|
97
|
+
* Function that should return a string containing a signed authentication token.
|
|
98
|
+
*/
|
|
99
|
+
tokenFactory?: AuthorizationTokenFactory;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Represents what authorization that will be requested.
|
|
103
|
+
*/
|
|
104
|
+
export interface AuthorizationContext {
|
|
105
|
+
/**
|
|
106
|
+
* The channelGroupId that might need authorization.
|
|
107
|
+
*/
|
|
108
|
+
channelGroupId?: string;
|
|
109
|
+
/**
|
|
110
|
+
* The channelId that might need authorization.
|
|
111
|
+
*/
|
|
112
|
+
channelId?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* AuthorizationTokenFactory
|
|
116
|
+
*/
|
|
117
|
+
export type AuthorizationTokenFactory = (context: AuthorizationContext) => string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Convenience class to call the public available endpoints of the Vindral Live CDN.
|
|
120
|
+
*/
|
|
121
|
+
export declare class ApiClient {
|
|
122
|
+
private baseUrl;
|
|
123
|
+
private tokenFactory?;
|
|
124
|
+
constructor(options: ApiClientOptions);
|
|
125
|
+
/**
|
|
126
|
+
* Returns everything needed to setup the connection of Vindral instance.
|
|
127
|
+
*/
|
|
128
|
+
connect(options: ConnectOptions): Promise<ConnectResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Fetches information regarding a single channel.
|
|
131
|
+
*
|
|
132
|
+
* @param channelId the channel to fetch
|
|
133
|
+
* @returns a [[Channel]] containing information about the requested channel.
|
|
134
|
+
*/
|
|
135
|
+
getChannel(channelId: string): Promise<Channel>;
|
|
136
|
+
/**
|
|
137
|
+
* Fetches channels within a channel group
|
|
138
|
+
*
|
|
139
|
+
* Note: The returned list includes inactive channels - check isLive to filter out only active channels
|
|
140
|
+
*
|
|
141
|
+
* @param channelGroup the channel group to fetch channels from
|
|
142
|
+
* @returns an array of [[Channel]] that belong to the channel group
|
|
143
|
+
*/
|
|
144
|
+
getChannels(channelGroupId: string): Promise<Channel[]>;
|
|
145
|
+
private getHeaders;
|
|
146
|
+
private getAuthToken;
|
|
147
|
+
private toChannels;
|
|
148
|
+
private toChannel;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export {};
|
package/api-client.js
ADDED
package/cast-sender.d.ts
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
|
|
2
|
+
type VoidKeys<Record> = MatchingKeys<Record, void>;
|
|
3
|
+
type EventListenerReturnType = (() => void) | void;
|
|
4
|
+
declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<TEvents> = VoidKeys<TEvents>, ArgEvents extends Exclude<keyof TEvents, ArgLessEvents> = Exclude<keyof TEvents, ArgLessEvents>, ArgLessEmits extends VoidKeys<TEmits> = VoidKeys<TEmits>, ArgEmits extends Exclude<keyof TEmits, ArgLessEmits> = Exclude<keyof TEmits, ArgLessEmits>> {
|
|
5
|
+
private listeners;
|
|
6
|
+
emit<T extends ArgLessEmits>(eventName: T): void;
|
|
7
|
+
emit<T extends ArgEmits>(eventName: T, args: TEmits[T]): void;
|
|
8
|
+
off<T extends ArgLessEvents>(eventName: T, fn: () => EventListenerReturnType): void;
|
|
9
|
+
off<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => EventListenerReturnType): void;
|
|
10
|
+
/**
|
|
11
|
+
* Add an event listener to `eventName`
|
|
12
|
+
*
|
|
13
|
+
* Event listeners may optionally return a "defer function" that will be called once all other listeners have been called.
|
|
14
|
+
* This is useful when one listener may want everone to have reacted to an event before calling something.
|
|
15
|
+
*/
|
|
16
|
+
on<T extends ArgLessEvents>(eventName: T, fn: () => void): void;
|
|
17
|
+
on<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
|
|
18
|
+
/**
|
|
19
|
+
* Add an event listener to `eventName` that will be called once only
|
|
20
|
+
*
|
|
21
|
+
* Event listeners may optionally return a "defer function" that will be called once all other listeners have been called.
|
|
22
|
+
* This is useful when one listener may want everone to have reacted to an event before calling something.
|
|
23
|
+
*/
|
|
24
|
+
once<T extends ArgLessEvents>(eventName: T, fn: () => void): void;
|
|
25
|
+
once<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
|
|
26
|
+
reset(): void;
|
|
27
|
+
private add;
|
|
28
|
+
}
|
|
29
|
+
declare const Levels: readonly [
|
|
30
|
+
"off",
|
|
31
|
+
"error",
|
|
32
|
+
"warn",
|
|
33
|
+
"info",
|
|
34
|
+
"debug",
|
|
35
|
+
"trace"
|
|
36
|
+
];
|
|
37
|
+
type Level = (typeof Levels)[number];
|
|
38
|
+
declare const Level: {
|
|
39
|
+
ERROR: "error";
|
|
40
|
+
WARN: "warn";
|
|
41
|
+
INFO: "info";
|
|
42
|
+
DEBUG: "debug";
|
|
43
|
+
TRACE: "trace";
|
|
44
|
+
OFF: "off";
|
|
45
|
+
};
|
|
46
|
+
type VideoCodec = "h264" | "av1";
|
|
47
|
+
interface Metadata {
|
|
48
|
+
/**
|
|
49
|
+
* The raw string content as it was ingested (if using JSON, it needs to be parsed on your end)
|
|
50
|
+
*/
|
|
51
|
+
content: string;
|
|
52
|
+
/**
|
|
53
|
+
* Timestamp in ms
|
|
54
|
+
*/
|
|
55
|
+
timestamp: number;
|
|
56
|
+
}
|
|
57
|
+
interface ReconnectState {
|
|
58
|
+
/**
|
|
59
|
+
* The number or retry attempts so far.
|
|
60
|
+
* This gets reset on every successful connect, so it will start from zero every
|
|
61
|
+
* time the client instance gets disconnected and will increment until the
|
|
62
|
+
* client instance makes a connection attempt is successful.
|
|
63
|
+
*/
|
|
64
|
+
reconnectRetries: number;
|
|
65
|
+
}
|
|
66
|
+
interface Size {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
}
|
|
70
|
+
interface VideoConstraint {
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
bitRate: number;
|
|
74
|
+
codec?: VideoCodec;
|
|
75
|
+
codecString?: string;
|
|
76
|
+
}
|
|
77
|
+
interface AdvancedOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Constrains wasm decoding to this resolution.
|
|
80
|
+
* By default it is set to 1280 in width and height.
|
|
81
|
+
* This guarantees better performance on older devices and reduces battery drain in general.
|
|
82
|
+
*/
|
|
83
|
+
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
84
|
+
}
|
|
85
|
+
type Media = "audio" | "video" | "audio+video";
|
|
86
|
+
interface Options {
|
|
87
|
+
/**
|
|
88
|
+
* URL to use when connecting to the stream
|
|
89
|
+
*/
|
|
90
|
+
url: string;
|
|
91
|
+
/**
|
|
92
|
+
* Channel ID to connect to initially - can be changed later mid-stream when connected to a channel group.
|
|
93
|
+
*/
|
|
94
|
+
channelId: string;
|
|
95
|
+
/**
|
|
96
|
+
* Channel group to connect to
|
|
97
|
+
* Note: Only needed for fast channel switching
|
|
98
|
+
*/
|
|
99
|
+
channelGroupId?: string;
|
|
100
|
+
/**
|
|
101
|
+
* A container to attach the video view in - can be provided later with .attach() on the vindral core instance
|
|
102
|
+
*/
|
|
103
|
+
container?: HTMLElement;
|
|
104
|
+
/**
|
|
105
|
+
* An authentication token to provide to the server when connecting - only needed for channels with authentication enabled
|
|
106
|
+
* Note: If not supplied when needed, an "Authentication Failed" error will be raised.
|
|
107
|
+
*/
|
|
108
|
+
authenticationToken?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Language to use initially - can be changed during during runtime on the vindral instance
|
|
111
|
+
* Note: Only needed when multiple languages are provided - if no language is specified, one will be automatically selected.
|
|
112
|
+
*/
|
|
113
|
+
language?: string;
|
|
114
|
+
/**
|
|
115
|
+
* TextTrack to use initially - can be changed during during runtime on the vindral instance
|
|
116
|
+
*/
|
|
117
|
+
textTrack?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Sets the log level - defaults to info
|
|
120
|
+
*/
|
|
121
|
+
logLevel?: Level;
|
|
122
|
+
/**
|
|
123
|
+
* Sets the minimum and initial buffer time
|
|
124
|
+
*/
|
|
125
|
+
minBufferTime?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Sets the maximum buffer time allowed. The vindral instance will automatically slowly increase
|
|
128
|
+
* the buffer time if the use experiences to much buffering with the initial buffer time.
|
|
129
|
+
*/
|
|
130
|
+
maxBufferTime?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Enables or disables user bandwidth savings by capping the video resolution to the size of the video element.
|
|
133
|
+
*
|
|
134
|
+
* Is enabled by default.
|
|
135
|
+
*
|
|
136
|
+
* Note: This is automatically set to false when abrEnabled is set to false.
|
|
137
|
+
*/
|
|
138
|
+
sizeBasedResolutionCapEnabled?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Enables or disables picture in picture support.
|
|
141
|
+
*/
|
|
142
|
+
pictureInPictureEnabled?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Enable bursting for initial connection and channel switches. This makes time to first frame faster at the
|
|
145
|
+
* cost of stability (more demanding due to the sudden burst of live content)
|
|
146
|
+
*
|
|
147
|
+
* Is disabled by default.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
burstEnabled?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Enable usage of the MediaSource API on supported browsers.
|
|
153
|
+
*
|
|
154
|
+
* Is enabled by default.
|
|
155
|
+
*
|
|
156
|
+
* Note: We recommend to keep this at the default value unless you have very specific needs.
|
|
157
|
+
*/
|
|
158
|
+
mseEnabled?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Enable Opus with the MediaSource API on supported browsers.
|
|
161
|
+
*
|
|
162
|
+
* Is enabled by default.
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
mseOpusEnabled?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Enable or disable support for playing audio in the background for iOS devices.
|
|
168
|
+
*
|
|
169
|
+
* Is false (disabled) by default.
|
|
170
|
+
*
|
|
171
|
+
* Note: This may be enabled by default in a future (major) release
|
|
172
|
+
*/
|
|
173
|
+
iosBackgroundPlayEnabled?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Enable or disable Adaptive Bit Rate. This allows for automatically adapting the incoming bit rate based on
|
|
176
|
+
* the viewers bandwidth and thus avoiding buffering events. This also disables the
|
|
177
|
+
* sizeBasedResolutionCapEnabled option.
|
|
178
|
+
*
|
|
179
|
+
* Is enabled by default.
|
|
180
|
+
*
|
|
181
|
+
* Note: It is strongly recommended to keep this enabled as user experience can greatly suffer without ABR.
|
|
182
|
+
*/
|
|
183
|
+
abrEnabled?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Enable or disable telemetry. This allows for telemetry and errors being collected.
|
|
186
|
+
*
|
|
187
|
+
* Is enabled by default.
|
|
188
|
+
*
|
|
189
|
+
* We appreciate you turning it off during development/staging to not bloat real telemetry data.
|
|
190
|
+
*
|
|
191
|
+
* Note: It is strongly recommended to keep this enabled in production as it is required for insights and KPIs.
|
|
192
|
+
*/
|
|
193
|
+
telemetryEnabled?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Set a cap on the maximum video size.
|
|
196
|
+
* This can be used to provide user options to limit the video bandwidth usage.
|
|
197
|
+
*
|
|
198
|
+
* Note: This takes presedence over any size based resolution caps.
|
|
199
|
+
*/
|
|
200
|
+
maxSize?: Size;
|
|
201
|
+
/**
|
|
202
|
+
* Maximum audio bit rate allowed.
|
|
203
|
+
* This can be used to provide user options to limit the audio bandwidth usage.
|
|
204
|
+
*/
|
|
205
|
+
maxAudioBitRate?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Maximum video bit rate allowed.
|
|
208
|
+
* This can be used to provide user options to limit the video bandwidth usage.
|
|
209
|
+
*/
|
|
210
|
+
maxVideoBitRate?: number;
|
|
211
|
+
/**
|
|
212
|
+
* Controls video element background behaviour while loading.
|
|
213
|
+
* - If `false`, a black background will be shown.
|
|
214
|
+
* - If undefined or `true`, a live thumbnail will be shown.
|
|
215
|
+
* - If set to a string containing a URL (https://urltoimage), use that.
|
|
216
|
+
* Default `true` - meaning a live thumbnail is shown
|
|
217
|
+
*/
|
|
218
|
+
poster?: boolean | string;
|
|
219
|
+
/**
|
|
220
|
+
* Whether to start the player muted or to try to start playing audio automatically.
|
|
221
|
+
*/
|
|
222
|
+
muted?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Provide a custom reconnect handler to control when the instance should stop trying to
|
|
225
|
+
* reconnect. The reconnect handler should either return true to allow the reconnect or
|
|
226
|
+
* false to stop reconnecting. It can also return a promise with true or false if it needs
|
|
227
|
+
* to make any async calls before determining wether to reconnect.
|
|
228
|
+
*
|
|
229
|
+
* The default reconnect handler allows 30 reconnects before stopping.
|
|
230
|
+
*
|
|
231
|
+
* Note: the ReconnectState gets reset every time the client instance makes a successful connection.
|
|
232
|
+
* This means the default reconnect handler will only stop reconnecting after 30 _consecutive_ failed connections.
|
|
233
|
+
*
|
|
234
|
+
* ```typescript
|
|
235
|
+
* // An example reconnect handler that will reconnect forever
|
|
236
|
+
* const reconnectHandler = (state: ReconnectState) => true
|
|
237
|
+
*
|
|
238
|
+
* // An example reconnect handler that will fetch an url and determine whether to reconnect
|
|
239
|
+
* const reconnectHandler = async (state: ReconnectState) => {
|
|
240
|
+
* const result = await fetch("https://should-i-reconnect-now.com")
|
|
241
|
+
* return result.ok
|
|
242
|
+
* },
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
reconnectHandler?: (state: ReconnectState) => Promise<boolean> | boolean;
|
|
246
|
+
tags?: string[];
|
|
247
|
+
ownerSessionId?: string;
|
|
248
|
+
edgeUrl?: string;
|
|
249
|
+
logShippingEnabled?: boolean;
|
|
250
|
+
statsShippingEnabled?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Enable wake lock for iOS devices.
|
|
253
|
+
* The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work.
|
|
254
|
+
* Other devices already provide wake lock by default.
|
|
255
|
+
*
|
|
256
|
+
* This option is redundant and has no effect if iosMediaElementEnabled is enabled since that automatically enables wake lock.
|
|
257
|
+
*
|
|
258
|
+
* Disabled by default.
|
|
259
|
+
*/
|
|
260
|
+
iosWakeLockEnabled?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Disabling this will revert to legacy behaviour where Vindral will try to always keep the video element playing.
|
|
263
|
+
*/
|
|
264
|
+
pauseSupportEnabled?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Enables iOS devices to use a media element for playback. This enables fullscreen and picture in picture support on iOS.
|
|
267
|
+
*/
|
|
268
|
+
iosMediaElementEnabled?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Advanced options to override default behaviour.
|
|
271
|
+
*/
|
|
272
|
+
advanced?: AdvancedOptions;
|
|
273
|
+
media?: Media;
|
|
274
|
+
videoCodecs?: VideoCodec[];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Available events to listen to
|
|
278
|
+
*/
|
|
279
|
+
export interface CastSenderEvents {
|
|
280
|
+
/**
|
|
281
|
+
* When a connection has been established with a CastReceiver
|
|
282
|
+
*/
|
|
283
|
+
["connected"]: void;
|
|
284
|
+
/**
|
|
285
|
+
* When a previous session has been resumed
|
|
286
|
+
*/
|
|
287
|
+
["resumed"]: void;
|
|
288
|
+
/**
|
|
289
|
+
* When a CastReceiver has lost or stopped a connection
|
|
290
|
+
*/
|
|
291
|
+
["disconnected"]: void;
|
|
292
|
+
/**
|
|
293
|
+
* When a connection attempt was initiated unsuccessfully
|
|
294
|
+
*/
|
|
295
|
+
["failed"]: void;
|
|
296
|
+
/**
|
|
297
|
+
* When the remote connection emits a metadata event
|
|
298
|
+
*/
|
|
299
|
+
["metadata"]: Metadata;
|
|
300
|
+
/**
|
|
301
|
+
* When the remote connection receives a server wallclock time event
|
|
302
|
+
*/
|
|
303
|
+
["server wallclock time"]: number;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Used for initializing the CastSender
|
|
307
|
+
*/
|
|
308
|
+
export interface CastConfig {
|
|
309
|
+
/**
|
|
310
|
+
* The [Vindral Options](./Options) to use for the Cast Receiver
|
|
311
|
+
*/
|
|
312
|
+
options: Options;
|
|
313
|
+
/**
|
|
314
|
+
* URL to a background image.
|
|
315
|
+
* Example: "https://via.placeholder.com/256x144"
|
|
316
|
+
*/
|
|
317
|
+
background?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Override this if you have your own custom receiver
|
|
320
|
+
*/
|
|
321
|
+
receiverApplicationId?: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* CastSender handles initiation of and communication with the Google Cast Receiver
|
|
325
|
+
*/
|
|
326
|
+
export declare class CastSender extends Emitter<CastSenderEvents> {
|
|
327
|
+
private state;
|
|
328
|
+
private config;
|
|
329
|
+
private unloaded;
|
|
330
|
+
constructor(config: CastConfig);
|
|
331
|
+
/**
|
|
332
|
+
* True if the instance is casting right now
|
|
333
|
+
*/
|
|
334
|
+
get casting(): boolean;
|
|
335
|
+
/**
|
|
336
|
+
* The current volume
|
|
337
|
+
*/
|
|
338
|
+
get volume(): number;
|
|
339
|
+
/**
|
|
340
|
+
* Set the current volume. Setting this to zero is equivalent to muting the video
|
|
341
|
+
*/
|
|
342
|
+
set volume(volume: number);
|
|
343
|
+
/**
|
|
344
|
+
* The current language
|
|
345
|
+
*/
|
|
346
|
+
get language(): string | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* Set the current language
|
|
349
|
+
*/
|
|
350
|
+
set language(language: string | undefined);
|
|
351
|
+
/**
|
|
352
|
+
* The current channelId
|
|
353
|
+
*/
|
|
354
|
+
get channelId(): string;
|
|
355
|
+
/**
|
|
356
|
+
* Set the current channelId
|
|
357
|
+
*/
|
|
358
|
+
set channelId(channelId: string);
|
|
359
|
+
/**
|
|
360
|
+
* Update authentication token on an already established and authenticated connection
|
|
361
|
+
*/
|
|
362
|
+
updateAuthenticationToken: (token: string) => void;
|
|
363
|
+
/**
|
|
364
|
+
* Fully unloads the instance. This disconnects the current listener but lets the
|
|
365
|
+
* cast session continue on the receiving device
|
|
366
|
+
*/
|
|
367
|
+
unload: () => void;
|
|
368
|
+
/**
|
|
369
|
+
* Initiates the CastSender.
|
|
370
|
+
* Will reject if Cast is not available on the device or the network.
|
|
371
|
+
*/
|
|
372
|
+
init: () => Promise<void>;
|
|
373
|
+
/**
|
|
374
|
+
* Requests a session. It will open the native cast receiver chooser dialog
|
|
375
|
+
*/
|
|
376
|
+
start: () => Promise<void>;
|
|
377
|
+
/**
|
|
378
|
+
* Stops a session. It will stop playback on device as well.
|
|
379
|
+
*/
|
|
380
|
+
stop: () => void;
|
|
381
|
+
/**
|
|
382
|
+
* Returns a string representing the name of the Cast receiver device or undefined if no receiver exists
|
|
383
|
+
*/
|
|
384
|
+
getReceiverName: () => string | undefined;
|
|
385
|
+
private onGCastApiAvailable;
|
|
386
|
+
private send;
|
|
387
|
+
private onMessage;
|
|
388
|
+
private onSessionStarted;
|
|
389
|
+
private onSessionStateChanged;
|
|
390
|
+
private getInstance;
|
|
391
|
+
private getSession;
|
|
392
|
+
private castLibrariesAdded;
|
|
393
|
+
private verifyCastLibraries;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export {};
|