You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes.
9
+
[api.video](https://api.video) is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes.
@@ -83,13 +100,15 @@ Then, once the `window.onload` event has been trigered, create your player using
83
100
</script>
84
101
```
85
102
86
-
# Instanciation
103
+
# Usage - Standard upload
104
+
105
+
## Instanciation
87
106
88
-
## Options
107
+
###Options
89
108
90
109
The upload library is instanciated using an `options` object. Options to provide depend on the way you want to authenticate to the API: either using a delegated upload token (recommanded), or using a usual access token.
91
110
92
-
### Using a delegated upload token (recommended):
111
+
####Using a delegated upload token (recommended):
93
112
94
113
Using delegated upload tokens for authentication is best options when uploading from the client side. To know more about delegated upload token, read the dedicated article on api.video's blog: [Delegated Uploads](https://api.video/blog/tutorials/delegated-uploads).
95
114
@@ -100,7 +119,7 @@ Using delegated upload tokens for authentication is best options when uploading
100
119
| videoId | no | string | id of an existing video |
101
120
|_common options (see bellow)_||||
102
121
103
-
### Using an access token (discouraged):
122
+
####Using an access token (discouraged):
104
123
105
124
**Warning**: be aware that exposing your access token client-side can lead to huge security issues. Use this method only if you know what you're doing :).
106
125
@@ -112,7 +131,7 @@ Using delegated upload tokens for authentication is best options when uploading
112
131
|_common options (see bellow)_||||
113
132
114
133
115
-
### Common options
134
+
####Common options
116
135
117
136
118
137
| Option name | Mandatory | Type | Description |
@@ -123,7 +142,7 @@ Using delegated upload tokens for authentication is best options when uploading
123
142
| retries | no | number | number of retries when an API call fails (default: 5) |
124
143
125
144
126
-
## Example
145
+
###Example
127
146
128
147
```javascript
129
148
constuploader=newVideoUploader({
@@ -134,15 +153,15 @@ Using delegated upload tokens for authentication is best options when uploading
134
153
});
135
154
```
136
155
137
-
# Methods
156
+
##Methods
138
157
139
-
## `upload()`
158
+
###`upload()`
140
159
141
160
The upload() method starts the upload. It takes no parameter. It returns a Promise that resolves once the file is uploaded. If an API call fails more than the specified number of retries, then the promise is rejected.
142
161
On success, the promise embeds the `video` object returned by the API.
143
162
On fail, the promise embeds the status code & error message returned by the API.
144
163
145
-
### Example
164
+
####Example
146
165
147
166
```javascript
148
167
// ... uploader instanciation
@@ -152,7 +171,7 @@ On fail, the promise embeds the status code & error message returned by the API.
The onProgress() method let you defined an upload progress listener. It takes a callback function with one parameter: the onProgress events.
158
177
An onProgress event contains the following attributes:
@@ -163,7 +182,7 @@ An onProgress event contains the following attributes:
163
182
- currentChunk (number): index of the chunk being uploaded
164
183
- currentChunkUploadedBytes (number): number of bytes uploaded for the current chunk
165
184
166
-
### Example
185
+
####Example
167
186
168
187
```javascript
169
188
// ... uploader instanciation
@@ -177,3 +196,104 @@ An onProgress event contains the following attributes:
177
196
console.log(`number of bytes uploaded for the current chunk: ${event.currentChunkUploadedBytes}.`);
178
197
});
179
198
```
199
+
200
+
# Usage - Progressive upload
201
+
202
+
203
+
## Instanciation
204
+
205
+
### Options
206
+
207
+
The progressive upload object is instanciated using an `options` object. Options to provide depend on the way you want to authenticate to the API: either using a delegated upload token (recommanded), or using a usual access token.
208
+
209
+
#### Using a delegated upload token (recommended):
210
+
211
+
Using delegated upload tokens for authentication is best options when uploading from the client side. To know more about delegated upload token, read the dedicated article on api.video's blog: [Delegated Uploads](https://api.video/blog/tutorials/delegated-uploads).
| uploadToken |**yes**| string | your upload token |
217
+
| videoId | no | string | id of an existing video |
218
+
|_common options (see bellow)_||||
219
+
220
+
#### Using an access token (discouraged):
221
+
222
+
**Warning**: be aware that exposing your access token client-side can lead to huge security issues. Use this method only if you know what you're doing :).
| retries | no | number | number of retries when an API call fails (default: 5) |
239
+
240
+
241
+
### Example
242
+
243
+
```javascript
244
+
constuploader=newProgressiveUploader({
245
+
uploadToken:"YOUR_DELEGATED_TOKEN",
246
+
retries:10,
247
+
});
248
+
```
249
+
250
+
## Methods
251
+
252
+
### `uploadPart(file: Blob)`
253
+
254
+
The upload() method starts the upload. It takes no parameter. It returns a Promise that resolves once the file is uploaded. If an API call fails more than the specified number of retries, then the promise is rejected.
255
+
On success, the promise embeds the `video` object returned by the API.
256
+
On fail, the promise embeds the status code & error message returned by the API.
The upload() method starts the upload. It takes no parameter. It returns a Promise that resolves once the file is uploaded. If an API call fails more than the specified number of retries, then the promise is rejected.
270
+
On success, the promise embeds the `video` object returned by the API.
271
+
On fail, the promise embeds the status code & error message returned by the API.
0 commit comments