Skip to content

Commit 7704532

Browse files
Merge pull request #12 from apivideo/add-origin-headers
Add origin headers
2 parents 6761e83 + b7cc23b commit 7704532

8 files changed

+710
-958
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.0.6] - 2022-07-06
5+
- Update dependancies
6+
- Add origin headers
7+
- Handle async errors
8+
49
## [1.0.5] - 2022-05-31
510
- Add `getMediaRecorderState()` method
611
- Fix `stop()` method when the recorder is not started

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [`start(options?: { timeslice?: number })`](#startoptions--timeslice-number-)
2828
- [Options](#options-1)
2929
- [`stop(): Promise<VideoUploadResponse>`](#stop-promisevideouploadresponse)
30+
- [`addEventListener(event: string, listener: Function)`](#addeventlistenerevent-string-listener-function)
3031
- [`getMediaRecorderState(): RecordingState`](#getmediarecorderstate-recordingstate)
3132
- [Full example](#full-example)
3233

@@ -178,9 +179,25 @@ The start() method starts the upload of the content retrieved from the MediaStre
178179

179180
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.
180181

182+
### `addEventListener(event: string, listener: Function)`
183+
184+
Define an event listener for the media recorder. The following events are available:
185+
- `"error"`: when an error occurs
186+
- `"recordingStopped"`: when the recording is stopped
187+
188+
**Example**
189+
190+
```javascript
191+
// ... mediaRecorder instanciation
192+
193+
mediaRecorder.addEventListener("error", (event) => {
194+
console.log(event.data);
195+
});
196+
```
197+
181198
### `getMediaRecorderState(): RecordingState`
182199

183-
Return the state of the underlaying [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder).
200+
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`.
184201

185202
**Example**
186203

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/index.d.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import { ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader";
2+
import { VideoUploadError } from "@api.video/video-uploader/dist/src/abstract-uploader";
23
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader";
4+
export { VideoUploadError } from "@api.video/video-uploader/dist/src/abstract-uploader";
35
export interface Options {
4-
title?: string;
6+
onError?: (error: VideoUploadError) => void;
57
}
8+
declare type EventType = "error" | "recordingStopped";
69
export declare class ApiVideoMediaRecorder {
710
private mediaRecorder;
811
private streamUpload;
912
private onVideoAvailable?;
10-
constructor(mediaStream: MediaStream, options: ProgressiveUploaderOptionsWithUploadToken | ProgressiveUploaderOptionsWithAccessToken);
13+
private onStopError?;
14+
private eventTarget;
15+
constructor(mediaStream: MediaStream, options: Options & (ProgressiveUploaderOptionsWithUploadToken | ProgressiveUploaderOptionsWithAccessToken));
16+
addEventListener(type: EventType, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void;
1117
private onDataAvailable;
18+
private dispatch;
1219
start(options?: {
1320
timeslice?: number;
1421
}): void;
1522
getMediaRecorderState(): RecordingState;
1623
stop(): Promise<VideoUploadResponse>;
1724
pause(): void;
25+
private stopMediaRecorder;
1826
private getSupportedMimeTypes;
1927
}

0 commit comments

Comments
 (0)