Skip to content

Commit

Permalink
Merge 249bb5f into 2f01b1d
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Feb 2, 2020
2 parents 2f01b1d + 249bb5f commit 5e99e75
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
@@ -1,6 +1,12 @@
videojs-record changelog
========================

3.10.0 - unreleased
-------------------

- Support constraints when recording screen-only or audio-screen (#)


3.9.0 - 2019/12/29
------------------

Expand Down
30 changes: 23 additions & 7 deletions src/js/videojs.record.js
Expand Up @@ -489,10 +489,19 @@ class Record extends Plugin {
audio: (this.audioRecorderType === AUTO) ? true : this.audioRecorderType,
video: (this.videoRecorderType === AUTO) ? true : this.videoRecorderType
};
navigator.mediaDevices.getDisplayMedia({
video: true // This needs to be true for Firefox to work
}).then(screenStream => {
navigator.mediaDevices.getUserMedia({ audio:this.recordAudio }).then((mic) => {
let audioScreenConstraints = {};
if (this.recordScreen === true) {
audioScreenConstraints = {
video: true // needs to be true for it to work in Firefox
};
} else if (typeof this.recordScreen === 'object' &&
this.recordScreen.constructor === Object) {
audioScreenConstraints = this.recordScreen;
}
navigator.mediaDevices.getDisplayMedia(audioScreenConstraints).then(screenStream => {
navigator.mediaDevices.getUserMedia({
audio: this.recordAudio
}).then((mic) => {
// Join microphone track with screencast stream (order matters)
screenStream.addTrack(mic.getTracks()[0]);
this.onDeviceReady.bind(this)(screenStream);
Expand Down Expand Up @@ -545,9 +554,16 @@ class Record extends Plugin {
screen: true,
gif: false
};
navigator.mediaDevices.getDisplayMedia({
video: true
}).then(
let screenOnlyConstraints = {};
if (this.recordScreen === true) {
screenOnlyConstraints = {
video: true
};
} else if (typeof this.recordScreen === 'object' &&
this.recordScreen.constructor === Object) {
screenOnlyConstraints = this.recordScreen;
}
navigator.mediaDevices.getDisplayMedia(screenOnlyConstraints).then(
this.onDeviceReady.bind(this)
).catch(
this.onDeviceError.bind(this)
Expand Down

0 comments on commit 5e99e75

Please sign in to comment.