Skip to content

Commit

Permalink
Merge pull request #11 from apivideo/fix-stop-when-not-started
Browse files Browse the repository at this point in the history
Fix stop() when not started
  • Loading branch information
olivierapivideo committed May 31, 2022
2 parents e1d6099 + 293c491 commit 6761e83
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All changes to this project will be documented in this file.

## [1.0.5] - 2022-05-31
- Add `getMediaRecorderState()` method
- Fix `stop()` method when the recorder is not started

## [1.0.4] - 2022-05-24
- Prevent last uploaded part to be empty

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
- [Methods](#methods)
- [`start(options?: { timeslice?: number })`](#startoptions--timeslice-number-)
- [Options](#options-1)
- [`stop()`](#stop)
- [`stop(): Promise<VideoUploadResponse>`](#stop-promisevideouploadresponse)
- [`getMediaRecorderState(): RecordingState`](#getmediarecorderstate-recordingstate)
- [Full example](#full-example)

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

### `stop()`
### `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.

### `getMediaRecorderState(): RecordingState`

Return the state of the underlaying [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder).

**Example**

```javascript
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader";
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken } from "@api.video/video-uploader";
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader";
export interface Options {
title?: string;
}
Expand All @@ -12,6 +12,7 @@ export declare class ApiVideoMediaRecorder {
start(options?: {
timeslice?: number;
}): void;
getMediaRecorderState(): RecordingState;
stop(): Promise<VideoUploadResponse>;
pause(): void;
private getSupportedMimeTypes;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api.video/media-recorder",
"version": "1.0.4",
"version": "1.0.5",
"description": "api.video media recorder - upload video from your webcam with ease",
"repository": {
"type": "git",
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProgressiveUploader, ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader";

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

export interface Options {
title?: string;
Expand Down Expand Up @@ -45,9 +45,13 @@ export class ApiVideoMediaRecorder {
this.mediaRecorder.start(options?.timeslice || 5000);
}

public getMediaRecorderState(): RecordingState {
return this.mediaRecorder.state;
}

public stop(): Promise<VideoUploadResponse> {
this.mediaRecorder.stop();
return new Promise((resolve, reject) => {
this.mediaRecorder.stop();
this.onVideoAvailable = (v) => resolve(v)
})
}
Expand Down

0 comments on commit 6761e83

Please sign in to comment.