@vindral/web-sdk 2.3.0 → 3.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/README.md +49 -15
- package/index.d.ts +1011 -1444
- package/index.mjs +6379 -0
- package/index.umd.js +37 -0
- package/package.json +19 -8
- package/style.css +1 -0
- package/web-sdk.esm.js +0 -15
- package/web-sdk.umd.js +0 -15
package/README.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# Vindral Web SDK
|
|
2
2
|
|
|
3
|
-
**Ultra
|
|
3
|
+
**Ultra-low latency streaming on all modern web browsers.**
|
|
4
4
|
|
|
5
|
-
This package contains the Web SDK for Vindral - the ultra
|
|
5
|
+
This package contains the Web SDK for Vindral - the ultra-low latency streaming platform for synchronized live experiences.
|
|
6
6
|
|
|
7
|
-
For information about the Vindral product family and how the Web SDK fits into the system, [make sure to
|
|
7
|
+
For information about the Vindral product family and how the Web SDK fits into the system, [make sure to check out the Vindral documentation](https://docs.vindral.com/).
|
|
8
8
|
|
|
9
|
-
Make sure to check out the
|
|
9
|
+
Make sure to check out the [Web SDK guides](https://docs.vindral.com/playout/websdk/getting-started/) as well.
|
|
10
10
|
|
|
11
11
|
[Check out our demo](https://demo.vindral.com/) to see some of Vindral's features.
|
|
12
12
|
|
|
13
13
|
## Getting Started
|
|
14
14
|
|
|
15
|
-
There are multiple ways to integrate the Web SDK, depending on use
|
|
15
|
+
There are multiple ways to integrate the Web SDK, depending on the use case.
|
|
16
16
|
|
|
17
17
|
The most simple way to get started is to use the iframe-based [Embed Player](#embed-player). This requires the least amount of code, and will automatically be updated when new releases are available.
|
|
18
18
|
|
|
19
|
-
The two other alternatives are [Player SDK](#player-sdk) and [Core SDK](#core-sdk) - these are the recommended options if the integration requires access to the APIs, such as timed metadata or other controls. The two SDKs have very similar APIs, but the Player SDK provides controls and buffering indication built in - the Core SDK is the most
|
|
19
|
+
The two other alternatives are [Player SDK](#player-sdk) and [Core SDK](#core-sdk) - these are the recommended options if the integration requires access to the APIs, such as timed metadata or other controls. The two SDKs have very similar APIs, but the Player SDK provides controls and buffering indication built in - the Core SDK is the most stripped-down implementation for use cases where all UI components are customized.
|
|
20
20
|
|
|
21
21
|
If you are going for one of the SDK alternatives, follow the steps at [Installation](#installation) to get started:
|
|
22
22
|
|
|
@@ -24,7 +24,7 @@ If you are going for one of the SDK alternatives, follow the steps at [Installat
|
|
|
24
24
|
|
|
25
25
|
This is the simplest way to integrate. It allows you to add a fully functional video player to your site in no time. It will also be automatically updated when improvements are released.
|
|
26
26
|
|
|
27
|
-
Add the following
|
|
27
|
+
Add the following HTML snippet, set `channelId` to channel id credential, and done!
|
|
28
28
|
|
|
29
29
|
```html
|
|
30
30
|
<iframe
|
|
@@ -34,7 +34,7 @@ Add the following html snippet, set `channelId` to channel id credential, done!
|
|
|
34
34
|
></iframe>
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
[See the player in action](https://embed.vindral.com/?channelId=vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f) or [read more about Embed Player here](https://docs.vindral.com/
|
|
37
|
+
[See the player in action](https://embed.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).
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
@@ -52,13 +52,13 @@ yarn add @vindral/web-sdk
|
|
|
52
52
|
|
|
53
53
|
### Player SDK
|
|
54
54
|
|
|
55
|
-
The Player SDK provides a ready-to-go player with controls - perfect for use
|
|
55
|
+
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.
|
|
56
56
|
|
|
57
57
|
**Example**
|
|
58
58
|
|
|
59
|
-
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
|
|
59
|
+
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.
|
|
60
60
|
|
|
61
|
-
The example assumes that there is
|
|
61
|
+
The example assumes that there is an HTML page that loads this script that has at least a div with `id="#root"`.
|
|
62
62
|
|
|
63
63
|
```javascript
|
|
64
64
|
import { Player } from "@vindral/web-sdk"
|
|
@@ -77,13 +77,33 @@ player.core.connect()
|
|
|
77
77
|
player.attach(root)
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
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:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import "@vindral/web-sdk/style.css"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
or, from a CSS file:
|
|
87
|
+
|
|
88
|
+
```css
|
|
89
|
+
@import "@vindral/web-sdk/style.css";
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
or, in your html file:
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<link rel="stylesheet" href="./node_modules/@vindral/web-sdk/style.css" />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
We recommend that you consult the documentation for your build tool for more information.
|
|
99
|
+
|
|
80
100
|
### Core SDK
|
|
81
101
|
|
|
82
102
|
The Core SDK is the lowest level method to integrate that provides only a video view and audio playback - this allows for full customization of the look of buffering indication, controls, etc.
|
|
83
103
|
|
|
84
104
|
**Example**
|
|
85
105
|
|
|
86
|
-
The example assumes that there is
|
|
106
|
+
The example assumes that there is an HTML page that loads this script that has at least a div with `id="#root"`, `id="#playback-state"` and a button with `id="#activate-audio-button"`.
|
|
87
107
|
|
|
88
108
|
```javascript
|
|
89
109
|
import { Vindral } from "@vindral/web-sdk"
|
|
@@ -110,7 +130,19 @@ instance.on("error", (error) => {
|
|
|
110
130
|
})
|
|
111
131
|
|
|
112
132
|
// This event is emitted when the playback state changes - can be used to show a buffer spinner during buffering
|
|
113
|
-
instance.on("playback state", (state) =>
|
|
133
|
+
instance.on("playback state", (state) => {
|
|
134
|
+
switch (state) {
|
|
135
|
+
case "paused":
|
|
136
|
+
// Here would be a good place to show some play button to allow the user to start playing again
|
|
137
|
+
break
|
|
138
|
+
case "playing":
|
|
139
|
+
// Hide any buffering or paused state from the UI
|
|
140
|
+
break
|
|
141
|
+
case "buffering":
|
|
142
|
+
// Show some buffering spinner
|
|
143
|
+
break
|
|
144
|
+
}
|
|
145
|
+
})
|
|
114
146
|
|
|
115
147
|
// This event is emitted when timed metadata events occur
|
|
116
148
|
instance.on("metadata", (metadata) => console.log("metadata: ", metadata.content))
|
|
@@ -119,7 +151,7 @@ instance.on("metadata", (metadata) => console.log("metadata: ", metadata.content
|
|
|
119
151
|
instance.on("needs user input", () => (button.style.display = "block"))
|
|
120
152
|
|
|
121
153
|
// Starts connecting to the channel
|
|
122
|
-
instance.
|
|
154
|
+
instance.play()
|
|
123
155
|
|
|
124
156
|
// Attaches the video view to the DOM
|
|
125
157
|
instance.attach(root)
|
|
@@ -127,7 +159,9 @@ instance.attach(root)
|
|
|
127
159
|
// This activates audio on browsers that need a user input before audio can be played
|
|
128
160
|
button.addEventListener("click", () => {
|
|
129
161
|
button.style.display = "none"
|
|
130
|
-
|
|
162
|
+
|
|
163
|
+
// Calling play again within a user click will activate audio if needed
|
|
164
|
+
instance.play()
|
|
131
165
|
})
|
|
132
166
|
```
|
|
133
167
|
|