Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK README - api.video-typescript-media-recorder] README to documentation synchro #348

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ title: api.video TypeScript Media Recorder
meta:
description: The official api.video TypeScript Media Recorder for api.video. [api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
---
<!--
THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
IF YOU NEED TO CHANGE THIS FILE, CREATE A PR IN THE SOURCE REPOSITORY.
-->

# api.video TypeScript Media Recorder

[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

## Project description


Typescript library to easily upload data from a [MediaStream](https://developer.mozilla.org/fr/docs/Web/API/MediaStream) to api.video.
It can be used to upload a video to api.video from the user's webcam with ease, as well as from a screen recording.

Expand Down Expand Up @@ -88,7 +93,7 @@ Then, once the `window.onload` event has been trigered, create your player using

The media recorder object is instantiated using a [MediaStream](https://developer.mozilla.org/fr/docs/Web/API/MediaStream) and 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.

#### Using a delegated upload token (recommended):
##### Using a delegated upload token (recommended):

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/).

Expand All @@ -99,7 +104,7 @@ Using delegated upload tokens for authentication is best options when uploading
| videoId | no | string | id of an existing video |
| _common options (see bellow)_ | | | |

#### Using an access token (discouraged):
##### Using an access token (discouraged):

**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 :).

Expand All @@ -111,7 +116,7 @@ Using delegated upload tokens for authentication is best options when uploading
| _common options (see bellow)_ | | | |


#### Common options
##### Common options


| Option name | Mandatory | Type | Description |
Expand All @@ -121,7 +126,7 @@ Using delegated upload tokens for authentication is best options when uploading
| videoName | no | string | the name of your recorded video (overrides the default "file" name) |


### Example
#### Example

```javascript
const mediaRecorder = new ApiVideoMediaRecorder(myMediaStream, {
Expand All @@ -130,13 +135,13 @@ Using delegated upload tokens for authentication is best options when uploading
});
```

## Methods
### Methods

### `start(options?: { timeslice?: number })`
#### `start(options?: { timeslice?: number })`

The start() method starts the upload of the content retrieved from the MediaStream. It takes an optionnal `options` parameter.

#### Options
##### Options
| Option name | Mandatory | Type | Description |
| ----------: | ------------------ | ------ | ---------------------------------------------------- |
| timeslice | no (default: 5000) | number | The number of milliseconds to record into each Blob. |
Expand All @@ -152,11 +157,11 @@ The start() method starts the upload of the content retrieved from the MediaStre
// mediaRecorder.start({ timeslice: 2000 });
```

### `stop(): Promise<VideoUploadResponse>`
#### `stop(): Promise<VideoUploadResponse>`

The start() method stops the media recording. It upload the last part of content retrieved from the MediaStream (this will start the aggregation of the video parts on the api.video side). It takes no parameter. It returns a Promise that resolves with the newly created video.

### `addEventListener(event: string, listener: Function)`
#### `addEventListener(event: string, listener: Function)`

Define an event listener for the media recorder. The following events are available:
- `"error"`: when an error occurs
Expand All @@ -173,7 +178,7 @@ Define an event listener for the media recorder. The following events are availa
});
```

### `getMediaRecorderState(): RecordingState`
#### `getMediaRecorderState(): RecordingState`

Return the state of the underlaying [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder). The state can be one of the following: `inactive`, `paused`, `recording`.

Expand Down Expand Up @@ -263,4 +268,4 @@ Return the state of the underlaying [MediaRecorder](https://developer.mozilla.or
</script>
</body>
</html>
```
```
Loading