Skip to content

Commit

Permalink
Merge branch 'master' of github.com:collab-project/videojs-record
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed May 22, 2021
2 parents 9631682 + d1ee1f5 commit 28b0964
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 4.5.0 - unreleased

- Add `convert` method and `convertAuto` option, allowing user
to control start of converter process (#568)
- Improve check in `removeRecording` (#575)
- Bump required version for webrtc-adapter (8.0.0 or newer)

Expand Down
1 change: 1 addition & 0 deletions docs/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ player.record().destroy();
| `setAudioOutput(deviceId)` | Change the audio output device using its [deviceId](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/deviceId). |
| `setAudioInput(deviceId)` | Change the audio input device using its [deviceId](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/deviceId). |
| `setVideoInput(deviceId)` | Change the video input device using its [deviceId](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/deviceId). |
| `convert` | Start converter manually (used with the `convertAuto: false` option) |
| `start` | Start recording. |
| `stop` | Stop recording. |
| `pause` | Pause recording. |
Expand Down
1 change: 1 addition & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ Additional options for this plugin are:
| `convertEngine` | string | `''` | Media converter library to use. Legal values are `ts-ebml`, `ffmpeg.wasm` and `ffmpeg.js`. Use an empty string `''` to disable (default). Inspect the [player.convertedData](recorded-data#convert-data) object for the converted data. |
| `convertWorkerURL` | string | `''` | URL for the converter worker, for example: `/node_modules/ffmpeg.js/ffmpeg-worker-mp4.js`. Currently only used for ffmpeg.wasm and ffmpeg.js plugins. Use an empty string '' to disable (default). |
| `convertOptions` | array | `[]` | List of string options to pass to the convert engine. |
| `convertAuto` | boolean | `true` | By default the converter automatically starts once recording completed. Use `false` to disable this behavior, allowing you to start the converter manually instead. |
| `hotKeys` | boolean or function | `false` | Enable [keyboard hotkeys](hotkeys.md). Disabled by default. |
| `pluginLibraryOptions` | object | `{}` | Use this object to specify additional settings for the library used by the plugin. Currently only used for the ffmpeg.wasm, ffmpeg.js, opus-recorder and vmsg plugins. |
3 changes: 3 additions & 0 deletions docs/recorded-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ player.on('finishConvert', function() {
});
```

If you do not want to convert the data automatically when the user stops recording,
set the `convertAuto` option to false and call `player.record().convert()` manually instead.

## Timestamps

It's also possible to get data during recording with specific time-intervals. This could
Expand Down
3 changes: 3 additions & 0 deletions src/js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ const pluginDefaultOptions = {
convertWorkerURL: '',
// List of string options to pass to the convert engine.
convertOptions: [],
// If the converter should automatically start after recording (default),
// or manually by calling `convert()`
convertAuto: true,
// Enable keyboard hotkeys.
hotKeys: false,
// Use this object to specify additional settings for the library used by the
Expand Down
17 changes: 14 additions & 3 deletions src/js/videojs.record.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class Record extends Plugin {

// convert settings
this.convertEngine = recordOptions.convertEngine;
this.convertAuto = recordOptions.convertAuto;
this.convertWorkerURL = recordOptions.convertWorkerURL;
this.convertOptions = recordOptions.convertOptions;

Expand Down Expand Up @@ -731,6 +732,7 @@ class Record extends Plugin {
}

// convert settings
this.converter.convertAuto = this.convertAuto;
this.converter.convertWorkerURL = this.convertWorkerURL;
this.converter.convertOptions = this.convertOptions;
this.converter.pluginLibraryOptions = this.pluginLibraryOptions;
Expand Down Expand Up @@ -1058,9 +1060,9 @@ class Record extends Plugin {
this.player.controlBar.playToggle.show();
}

// notify converter
if (this.converter !== undefined) {
this.converter.convert(this.player.recordedData);
// start converter
if (this.convertAuto === true) {
this.convert();
}

// notify listeners that data is available
Expand Down Expand Up @@ -1557,6 +1559,15 @@ class Record extends Plugin {
this.recordVideo, this.recordAnimation, this.recordScreen);
}

/**
* Start converter.
*/
convert() {
if (this.converter !== undefined) {
this.converter.convert(this.player.recordedData);
}
}

/**
* Create and display snapshot image.
* @private
Expand Down
1 change: 1 addition & 0 deletions test/defaults.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('pluginDefaultOptions', () => {
convertEngine: '',
convertWorkerURL: '',
convertOptions: [],
convertAuto: true,
hotKeys: false,
pluginLibraryOptions: {}
});
Expand Down

0 comments on commit 28b0964

Please sign in to comment.