Skip to content

Commit

Permalink
Merge pull request #154 from apivideo/documentation-typescript-media-…
Browse files Browse the repository at this point in the history
…recorder

[SDK README - api.video-typescript-media-recorder] README to documentation synchro
  • Loading branch information
bot-api-video authored Nov 14, 2023
2 parents 0707620 + 05899b6 commit 929c070
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions sdks/vod/apivideo-typescript-media-recorder.md
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>
```
```

0 comments on commit 929c070

Please sign in to comment.