Skip to content

Commit 62fae2d

Browse files
committed
Enhancment in the Flipped Feature
1 parent 3e47842 commit 62fae2d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/dom/dom.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,35 +2246,34 @@ p5.prototype.createCapture = function(...args) {
22462246
if (arg === p5.prototype.VIDEO) useAudio = false;
22472247
else if (arg === p5.prototype.AUDIO) useVideo = false;
22482248
else if (typeof arg === 'object') {
2249-
// Check if the argument is an object with a 'flipped' property
22502249
if (arg.flipped !== undefined) {
22512250
flipped = arg.flipped;
2252-
} else {
2253-
constraints = arg;
2251+
delete arg.flipped;
22542252
}
2253+
constraints = Object.assign({}, constraints, arg);
22552254
}
22562255
else if (typeof arg === 'function') {
22572256
callback = arg;
22582257
}
22592258
}
22602259

2261-
if (!constraints) constraints = { video: useVideo, audio: useAudio };
2262-
2260+
const videoConstraints = { video: useVideo, audio: useAudio };
2261+
constraints = Object.assign({}, videoConstraints, constraints);
22632262
const domElement = document.createElement('video');
22642263
// required to work in iOS 11 & up:
22652264
domElement.setAttribute('playsinline', '');
2266-
22672265
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
22682266
try {
22692267
if ('srcObject' in domElement) {
22702268
domElement.srcObject = stream;
22712269
} else {
22722270
domElement.src = window.URL.createObjectURL(stream);
22732271
}
2274-
} catch (err) {
2272+
}
2273+
catch(err) {
22752274
domElement.src = stream;
22762275
}
2277-
}, console.log);
2276+
}, console.err);
22782277

22792278
const videoEl = addElement(domElement, this, true);
22802279
videoEl.loadedmetadata = false;

0 commit comments

Comments
 (0)