diff --git a/index.html b/index.html new file mode 100644 index 0000000..a6626db --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + + + + + Media recorder example + + + + + + + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..4de8321 --- /dev/null +++ b/index.js @@ -0,0 +1,23 @@ +function hasGetUserMedia() { + return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia); +} + +function getDeviceAccess() { + const constraints = { + video: true, + audio: true + }; + + const video = document.querySelector("video"); + + // todo avoid to play sound (only display video feedback) + navigator.mediaDevices.getUserMedia(constraints).then((stream) => { + video.srcObject = stream; + }); +} + +if (hasGetUserMedia()) { + getDeviceAccess() +} else { + alert("getUserMedia() is not supported by your browser"); +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..e69de29