@bigbinary/neeto-media-recorder 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +263 -1
- package/core.js +0 -16
- package/core.js.map +1 -1
- package/index.js +59 -44
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,263 @@
|
|
|
1
|
-
# neeto-media-recorder
|
|
1
|
+
# @bigbinary/neeto-media-recorder
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
yarn add @bigbinary/neeto-media-recorder
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
This package exports four different sets of functions and components.
|
|
15
|
+
|
|
16
|
+
1. [Components](#components)
|
|
17
|
+
2. [Utilities](#utilities)
|
|
18
|
+
3. [Constants](#constants)
|
|
19
|
+
4. [Core](#core)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Components
|
|
23
|
+
- #### MediaRecorder
|
|
24
|
+
|
|
25
|
+
The `MediaRecorder` react component capture's device screen and upload it to the AWS S3 storage. It contains UI controls to start, pause/resume, discard and restart a recording.
|
|
26
|
+
|
|
27
|
+
You can import the components from `@bigbinary/neeto-media-recorder`.
|
|
28
|
+
```js
|
|
29
|
+
import { MediaRecorder } from "@bigbinary/neeto-media-recorder"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`MediaRecorder` accepts two props:
|
|
33
|
+
|
|
34
|
+
- `onUploadComplete`: This callback will get triggered once the uploading of the screen recording is completed.
|
|
35
|
+
- `onDiscard`: This callback will get triggered whenever the user discard's the screen recording.
|
|
36
|
+
|
|
37
|
+
### Utilities
|
|
38
|
+
|
|
39
|
+
You can import utilities from `@bigbinary/neeto-media-recorder/utils`.
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { generatePublicUrl } from "@bigbinary/neeto-media-recorder/utils"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- #### `generatePublicUrl(recordingId)`
|
|
46
|
+
Can be used to generate the public URL for a screen recording by providing the `recordingId` as an argument.
|
|
47
|
+
|
|
48
|
+
### Constants
|
|
49
|
+
|
|
50
|
+
You can import constants from `@bigbinary/neeto-media-recorder/constants`.
|
|
51
|
+
```js
|
|
52
|
+
import { UPLOAD_EVENT, UPLOAD_STATUS,... } from "@bigbinary/neeto-media-recorder/constants"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The available constants are:
|
|
56
|
+
```js
|
|
57
|
+
const UPLOAD_EVENT = { onComplete: "onComplete" };
|
|
58
|
+
|
|
59
|
+
const UPLOAD_STATUS = {
|
|
60
|
+
uploading: "uploading",
|
|
61
|
+
completed: "completed",
|
|
62
|
+
aborting: "aborting",
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const SCREEN_RECORDER_STATUS = {
|
|
66
|
+
media_aborted: "media_aborted",
|
|
67
|
+
permission_denied: "permission_denied",
|
|
68
|
+
no_specified_media_found: "no_specified_media_found",
|
|
69
|
+
media_in_use: "media_in_use",
|
|
70
|
+
invalid_media_constraints: "invalid_media_constraints",
|
|
71
|
+
no_chrome_flags_set: "no_chrome_flags_set",
|
|
72
|
+
recorder_error: "recorder_error",
|
|
73
|
+
idle: "idle",
|
|
74
|
+
acquiring_media: "acquiring_media",
|
|
75
|
+
media_acquired: "media_acquired",
|
|
76
|
+
restarting: "restarting",
|
|
77
|
+
recording: "recording",
|
|
78
|
+
stopping: "stopping",
|
|
79
|
+
stopped: "stopped",
|
|
80
|
+
paused: "paused",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const SCREEN_RECORDER_ERROR = {
|
|
84
|
+
AbortError: "media_aborted",
|
|
85
|
+
NotAllowedError: "permission_denied",
|
|
86
|
+
NotFoundError: "no_specified_media_found",
|
|
87
|
+
NotReadableError: "media_in_use",
|
|
88
|
+
OverconstrainedError: "invalid_media_constraints",
|
|
89
|
+
TypeError: "no_chrome_flags_set",
|
|
90
|
+
None: "",
|
|
91
|
+
NoRecorder: "recorder_error",
|
|
92
|
+
UnSupportedBrowser: "unsupported_browser",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const SCREEN_RECORDER_EVENT = {
|
|
96
|
+
onStart: "onStart",
|
|
97
|
+
onStop: "onStop",
|
|
98
|
+
onDiscard: "onDiscard",
|
|
99
|
+
onDataAvailable: "onDataAvailable",
|
|
100
|
+
onDiscardDuringCountdown: "onDiscardDuringCountdown",
|
|
101
|
+
onRestart: "onRestart",
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Core
|
|
106
|
+
|
|
107
|
+
The `@bigbinary/neeto-media-recorder/core` contains two singleton class's `screenRecorder` and `multipartS3Uploader`.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import { screenRecorder, multipartS3Uploader } from "@bigbinary/neeto-media-recorder/core"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- #### screenRecorder
|
|
114
|
+
It handles the screen and audio capturing process. The various methods provided by `screenRecorder` are:
|
|
115
|
+
|
|
116
|
+
- `startRecording()`
|
|
117
|
+
|
|
118
|
+
Used to start screen recording.
|
|
119
|
+
|
|
120
|
+
- `stopRecording()`
|
|
121
|
+
|
|
122
|
+
Used to stop the current screen recording.
|
|
123
|
+
|
|
124
|
+
- `pauseRecording()`
|
|
125
|
+
|
|
126
|
+
Used to pause the current screen recording.
|
|
127
|
+
|
|
128
|
+
- `resumeRecording()`
|
|
129
|
+
|
|
130
|
+
Used to resume the screen recording.
|
|
131
|
+
|
|
132
|
+
- `discardRecording()`
|
|
133
|
+
|
|
134
|
+
Used to discard the current screen recording.
|
|
135
|
+
|
|
136
|
+
- `restartRecording()`
|
|
137
|
+
|
|
138
|
+
Used to discard the current screen recording and start a new one.
|
|
139
|
+
|
|
140
|
+
- `addCallback(event, callback)`
|
|
141
|
+
|
|
142
|
+
Used to add callback function for a specific screen recording event. The constant `SCREEN_RECORDER_EVENT` contains all the possible screen recording events.
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onStart, handleStartRecording)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- `removeCallback(event, callback)`
|
|
149
|
+
|
|
150
|
+
Used to remove an already added callback by providing the event and callback to be removed.
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
screenRecorder.removeCallback(SCREEN_RECORDER_EVENT.onStart, handleStartRecording)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- `removeAllCallbacksByEvent(event)`
|
|
157
|
+
|
|
158
|
+
Used to remove all callbacks associated with a particular event.
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
screenRecorder.removeCallback(SCREEN_RECORDER_EVENT.onStart)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
- `resetState()`
|
|
165
|
+
|
|
166
|
+
Used to reset the internal states of the screenRecorder to initial state.
|
|
167
|
+
|
|
168
|
+
- `revokePermissions()`
|
|
169
|
+
|
|
170
|
+
Used to revoke the browser permission to access the MediaRecorder api.
|
|
171
|
+
|
|
172
|
+
- `useRecorderStore()`
|
|
173
|
+
|
|
174
|
+
A zustand store which can be used know the screenRecorder status and error if any occurred inside a react component
|
|
175
|
+
|
|
176
|
+
- #### multipartS3Uploader
|
|
177
|
+
It handles the upload of recorded screen data to AWS S3 storage. `multipartS3Uploader` provides the ability to upload the recording to S3 in multiple chunks. The methods provided `multipartS3Uploader` are:
|
|
178
|
+
|
|
179
|
+
- `initialize(recordingId, uploadId)`
|
|
180
|
+
|
|
181
|
+
Used to initialize the `multipartS3Uploader` by providing the `recordingId` and `uploadId`. `recordingId` and `uploadId` can be obtained by creating a new recording in `neeto-record-web`.
|
|
182
|
+
|
|
183
|
+
- `push(data)`
|
|
184
|
+
|
|
185
|
+
Used to upload the recorded chunk to S3.
|
|
186
|
+
|
|
187
|
+
- `completeUpload()`
|
|
188
|
+
|
|
189
|
+
Once the recording is completed this method should be called to mark the recording as completed.
|
|
190
|
+
|
|
191
|
+
- `abortUpload()`
|
|
192
|
+
|
|
193
|
+
Used to discard the partially uploaded recording.
|
|
194
|
+
|
|
195
|
+
- `resetState()`
|
|
196
|
+
|
|
197
|
+
Used to reset the internal state of multipartS3Uploader to initial state.
|
|
198
|
+
|
|
199
|
+
- `addCallback(event, callback)`
|
|
200
|
+
|
|
201
|
+
Used to add callback function to a specific upload event. The constant `UPLOAD_EVENT` contains all the possible upload events.
|
|
202
|
+
|
|
203
|
+
- `removeCallback(event, callback)`
|
|
204
|
+
|
|
205
|
+
Used to remove an already added callback by providing the event and callback to be removed.
|
|
206
|
+
|
|
207
|
+
- `useMultipartS3UploadStore()`
|
|
208
|
+
|
|
209
|
+
A zustand store which can be used know the screenRecorder status inside a react component.
|
|
210
|
+
|
|
211
|
+
## Development
|
|
212
|
+
|
|
213
|
+
Install all the dependencies by executing the following command
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
yarn install
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Using host application
|
|
220
|
+
|
|
221
|
+
1. Clone this repository.
|
|
222
|
+
2. Run `yarn install` to download the dependencies and setup the development
|
|
223
|
+
environment.
|
|
224
|
+
3. Have a host application ready.
|
|
225
|
+
4. Run `yarn watch` to automatically transpile code as you save the
|
|
226
|
+
file. You can run `yarn build` if you want to run the build only once.
|
|
227
|
+
5. In a different terminal, run `yalc publish` to publish the
|
|
228
|
+
neeto-media-recorder to the local yalc store.
|
|
229
|
+
6. Run `yalc add @bigbinary/neeto-media-recorder` to install the
|
|
230
|
+
neeto-media-recorder to the host application.
|
|
231
|
+
7. After making necessary changes to `neeto-media-recorder`, run
|
|
232
|
+
`yarn release` to push the changes to the host application (assuming that you
|
|
233
|
+
are in watch mode and the changes are bundled automatically). Restart
|
|
234
|
+
webpack-dev-server in host if changes are not applied.
|
|
235
|
+
8. Video explanation on how to use yalc: https://www.youtube.com/watch?v=QBiYGP0Rhe0
|
|
236
|
+
|
|
237
|
+
# Building and releasing.
|
|
238
|
+
|
|
239
|
+
The `@bigbinary/neeto-neeto-media-recorder` package gets published to NPM when we merge a
|
|
240
|
+
PR with `patch`, `minor` or `major` label to the `main` branch. The `patch`
|
|
241
|
+
label is used for bug fixes, `minor` label is used for new features and `major`
|
|
242
|
+
label is used for breaking changes. You can checkout the
|
|
243
|
+
`Create and publish releases` workflow in GitHub Actions to get a live update.
|
|
244
|
+
|
|
245
|
+
In case if you missed to add the label, you can manually publish the package.
|
|
246
|
+
For that first you need to create a PR to update the version number in the
|
|
247
|
+
`package.json` file and merge it to the `main` branch. After merging the PR, you
|
|
248
|
+
need to create a
|
|
249
|
+
[new github release](https://github.com/bigbinary/neeto-media-recorder/releases/new)
|
|
250
|
+
from main branch. Whenever a new release is created with a new version number,
|
|
251
|
+
the github actions will automatically publish the built package to npm. You can
|
|
252
|
+
checkout the `Publish to npm` workflow in GitHub Actions to get a live update.
|
|
253
|
+
|
|
254
|
+
Please note that before publishing the package, you need to verify the
|
|
255
|
+
functionality in some of the neeto web-apps locally using `yalc` package
|
|
256
|
+
manager.
|
|
257
|
+
|
|
258
|
+
# Project integrations
|
|
259
|
+
|
|
260
|
+
| Projects | neeto-media-recorder |
|
|
261
|
+
|:-----------------------------:|:----------------------:|
|
|
262
|
+
| neeto-record-web | :white_check_mark: |
|
|
263
|
+
| neeto-record-chrome-extension | :white_check_mark: |
|
package/core.js
CHANGED
|
@@ -3713,22 +3713,6 @@ var ScreenRecorder = /*#__PURE__*/function () {
|
|
|
3713
3713
|
writable: true,
|
|
3714
3714
|
value: void 0
|
|
3715
3715
|
});
|
|
3716
|
-
_defineProperty$1(this, "getPreviewStream", function () {
|
|
3717
|
-
return new MediaStream(_classPrivateFieldGet(_this, _mediaStream).getVideoTracks());
|
|
3718
|
-
});
|
|
3719
|
-
_defineProperty$1(this, "getMediaBlobUrl", function () {
|
|
3720
|
-
var blob = new Blob(_classPrivateFieldGet(_this, _mediaChunks), {
|
|
3721
|
-
type: 'video/webm;codecs="vp9"'
|
|
3722
|
-
});
|
|
3723
|
-
|
|
3724
|
-
// TODO: Revoke the object url
|
|
3725
|
-
return URL.createObjectURL(blob);
|
|
3726
|
-
});
|
|
3727
|
-
_defineProperty$1(this, "getWebmMediaBlob", function () {
|
|
3728
|
-
return new Blob(_classPrivateFieldGet(_this, _mediaChunks), {
|
|
3729
|
-
type: 'video/webm;codecs="vp9"'
|
|
3730
|
-
});
|
|
3731
|
-
});
|
|
3732
3716
|
_defineProperty$1(this, "addCallback", function (event, callback) {
|
|
3733
3717
|
var _classPrivateFieldGet2;
|
|
3734
3718
|
var existingCallbacks = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _callbacks)[event]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : [];
|