Skip to content

Commit e774856

Browse files
Merge pull request #14 from apivideo/video-playable-event
Add videoPlayable event
2 parents 8831932 + 4f23676 commit e774856

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

CHANGELOG.md

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

4+
## [1.0.8] - 2023-01-23
5+
- Add "videoPlayable" event
6+
47
## [1.0.7] - 2022-10-10
58
- Allow the user to customize the recorded video's name
69

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ The start() method stops the media recording. It upload the last part of content
185185
Define an event listener for the media recorder. The following events are available:
186186
- `"error"`: when an error occurs
187187
- `"recordingStopped"`: when the recording is stopped
188+
- `"videoPlayable"`: when the video is playable
188189

189190
**Example**
190191

examples/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
uploadToken: "UPLOAD_TOKEN",
6060
videoName: videoName
6161
});
62+
63+
recorder.addEventListener("videoPlayable", (e) => console.log("Video playable,", e));
6264

6365
recorder.start();
6466

package-lock.json

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

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api.video/media-recorder",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "api.video media recorder - upload video from your webcam with ease",
55
"repository": {
66
"type": "git",
@@ -39,7 +39,7 @@
3939
"xhr-mock": "^2.5.1"
4040
},
4141
"dependencies": {
42-
"@api.video/video-uploader": "^1.1.0",
42+
"@api.video/video-uploader": "^1.1.3",
4343
"core-js": "^3.23.3"
4444
}
4545
}

src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProgressiveUploader, ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader";
1+
import { ProgressiveUploader, ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader";
22
import { VideoUploadError } from "@api.video/video-uploader/dist/src/abstract-uploader";
33

44
export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader";
@@ -16,7 +16,7 @@ try {
1616
// ignore
1717
}
1818

19-
type EventType = "error" | "recordingStopped";
19+
type EventType = "error" | "recordingStopped" | "videoPlayable";
2020

2121

2222
export class ApiVideoMediaRecorder {
@@ -53,6 +53,9 @@ export class ApiVideoMediaRecorder {
5353
}
5454

5555
public addEventListener(type: EventType, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void {
56+
if(type === "videoPlayable") {
57+
this.streamUpload.onPlayable((video) => this.dispatch("videoPlayable", video));
58+
}
5659
this.eventTarget.addEventListener(type, callback, options);
5760
}
5861

0 commit comments

Comments
 (0)