Skip to content

Commit

Permalink
Merge pull request #14 from apivideo/video-playable-event
Browse files Browse the repository at this point in the history
Add videoPlayable event
  • Loading branch information
olivier-lando authored Jan 23, 2023
2 parents 8831932 + 4f23676 commit e774856
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
2 changes: 2 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
uploadToken: "UPLOAD_TOKEN",
videoName: videoName
});

recorder.addEventListener("videoPlayable", (e) => console.log("Video playable,", e));

recorder.start();

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -16,7 +16,7 @@ try {
// ignore
}

type EventType = "error" | "recordingStopped";
type EventType = "error" | "recordingStopped" | "videoPlayable";


export class ApiVideoMediaRecorder {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit e774856

Please sign in to comment.