diff --git a/CHANGELOG.md b/CHANGELOG.md index a72d1b6..929f208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [1.0.8] - 2023-01-23 +- Add "videoPlayable" event + ## [1.0.7] - 2022-10-10 - Allow the user to customize the recorded video's name diff --git a/README.md b/README.md index 16740a4..b7ea98e 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ The start() method stops the media recording. It upload the last part of content Define an event listener for the media recorder. The following events are available: - `"error"`: when an error occurs - `"recordingStopped"`: when the recording is stopped +- `"videoPlayable"`: when the video is playable **Example** diff --git a/examples/index.html b/examples/index.html index bd188e3..1db99d4 100644 --- a/examples/index.html +++ b/examples/index.html @@ -59,6 +59,8 @@ uploadToken: "UPLOAD_TOKEN", videoName: videoName }); + + recorder.addEventListener("videoPlayable", (e) => console.log("Video playable,", e)); recorder.start(); diff --git a/package-lock.json b/package-lock.json index 60fbafe..963cb3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@api.video/media-recorder", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api.video/media-recorder", - "version": "1.0.7", + "version": "1.0.8", "license": "MIT", "dependencies": { - "@api.video/video-uploader": "^1.1.0", + "@api.video/video-uploader": "^1.1.3", "core-js": "^3.23.3" }, "devDependencies": { @@ -30,9 +30,9 @@ } }, "node_modules/@api.video/video-uploader": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@api.video/video-uploader/-/video-uploader-1.1.0.tgz", - "integrity": "sha512-TZtseBEvSbm6aSd/I7apGnYnjssqKBLtHWOGzEozVSGmxgvxFPj21U2dd+DNFw8ycEr3GjKkyyZGGKQXyVrE4g==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@api.video/video-uploader/-/video-uploader-1.1.3.tgz", + "integrity": "sha512-TuEYsBEFXnJZM7tSnFwemam+AdJzlpT1ZBI1PMB7ssTAMFY62HRyCYHD7bleEGYi4FjxaCVraQvkouNtyk5UpQ==", "dependencies": { "core-js": "^3.25.5" } @@ -3451,9 +3451,9 @@ }, "dependencies": { "@api.video/video-uploader": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@api.video/video-uploader/-/video-uploader-1.1.0.tgz", - "integrity": "sha512-TZtseBEvSbm6aSd/I7apGnYnjssqKBLtHWOGzEozVSGmxgvxFPj21U2dd+DNFw8ycEr3GjKkyyZGGKQXyVrE4g==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@api.video/video-uploader/-/video-uploader-1.1.3.tgz", + "integrity": "sha512-TuEYsBEFXnJZM7tSnFwemam+AdJzlpT1ZBI1PMB7ssTAMFY62HRyCYHD7bleEGYi4FjxaCVraQvkouNtyk5UpQ==", "requires": { "core-js": "^3.25.5" } diff --git a/package.json b/package.json index b07518a..0ee6dde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@api.video/media-recorder", - "version": "1.0.7", + "version": "1.0.8", "description": "api.video media recorder - upload video from your webcam with ease", "repository": { "type": "git", @@ -39,7 +39,7 @@ "xhr-mock": "^2.5.1" }, "dependencies": { - "@api.video/video-uploader": "^1.1.0", + "@api.video/video-uploader": "^1.1.3", "core-js": "^3.23.3" } } diff --git a/src/index.ts b/src/index.ts index 4f6a45b..ae832cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { ProgressiveUploader, ProgressiveUploaderOptionsWithUploadToken, ProgressiveUploaderOptionsWithAccessToken, VideoUploadResponse } from "@api.video/video-uploader"; +import { ProgressiveUploader, ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader"; import { VideoUploadError } from "@api.video/video-uploader/dist/src/abstract-uploader"; export { ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken, VideoUploadResponse } from "@api.video/video-uploader"; @@ -16,7 +16,7 @@ try { // ignore } -type EventType = "error" | "recordingStopped"; +type EventType = "error" | "recordingStopped" | "videoPlayable"; export class ApiVideoMediaRecorder { @@ -53,6 +53,9 @@ export class ApiVideoMediaRecorder { } public addEventListener(type: EventType, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void { + if(type === "videoPlayable") { + this.streamUpload.onPlayable((video) => this.dispatch("videoPlayable", video)); + } this.eventTarget.addEventListener(type, callback, options); }