Skip to content

Commit 6761e83

Browse files
Merge pull request #11 from apivideo/fix-stop-when-not-started
Fix stop() when not started
2 parents e1d6099 + 293c491 commit 6761e83

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

CHANGELOG.md

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

4+
## [1.0.5] - 2022-05-31
5+
- Add `getMediaRecorderState()` method
6+
- Fix `stop()` method when the recorder is not started
7+
48
## [1.0.4] - 2022-05-24
59
- Prevent last uploaded part to be empty
610

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
- [Methods](#methods)
2727
- [`start(options?: { timeslice?: number })`](#startoptions--timeslice-number-)
2828
- [Options](#options-1)
29-
- [`stop()`](#stop)
29+
- [`stop(): Promise<VideoUploadResponse>`](#stop-promisevideouploadresponse)
30+
- [`getMediaRecorderState(): RecordingState`](#getmediarecorderstate-recordingstate)
3031
- [Full example](#full-example)
3132

3233
# Project description
@@ -173,10 +174,14 @@ The start() method starts the upload of the content retrieved from the MediaStre
173174
// mediaRecorder.start({ timeslice: 2000 });
174175
```
175176

176-
### `stop()`
177+
### `stop(): Promise<VideoUploadResponse>`
177178

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

181+
### `getMediaRecorderState(): RecordingState`
182+
183+
Return the state of the underlaying [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder).
184+
180185
**Example**
181186

182187
```javascript

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader";
2-
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken } from "@api.video/video-uploader";
2+
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader";
33
export interface Options {
44
title?: string;
55
}
@@ -12,6 +12,7 @@ export declare class ApiVideoMediaRecorder {
1212
start(options?: {
1313
timeslice?: number;
1414
}): void;
15+
getMediaRecorderState(): RecordingState;
1516
stop(): Promise<VideoUploadResponse>;
1617
pause(): void;
1718
private getSupportedMimeTypes;

package-lock.json

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api.video/media-recorder",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "api.video media recorder - upload video from your webcam with ease",
55
"repository": {
66
"type": "git",

src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ProgressiveUploader, ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader";
22

3-
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken } from "@api.video/video-uploader";
3+
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader";
44

55
export interface Options {
66
title?: string;
@@ -45,9 +45,13 @@ export class ApiVideoMediaRecorder {
4545
this.mediaRecorder.start(options?.timeslice || 5000);
4646
}
4747

48+
public getMediaRecorderState(): RecordingState {
49+
return this.mediaRecorder.state;
50+
}
51+
4852
public stop(): Promise<VideoUploadResponse> {
49-
this.mediaRecorder.stop();
5053
return new Promise((resolve, reject) => {
54+
this.mediaRecorder.stop();
5155
this.onVideoAvailable = (v) => resolve(v)
5256
})
5357
}

0 commit comments

Comments
 (0)