This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
class VideoChat extends React.Component { | |
state = { | |
source: "" | |
} | |
componentDidMount(){ | |
navigator.mediaDevices.getUserMedia({video: true, audio: true}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const videoPlayer = document.getElementById("video-player") // this is a <video> element | |
onSuccessWithSrcObject(stream) { | |
videoPlayer.srcObject = stream; | |
} | |
onSuccessWithSrc(stream) { | |
videoPlayer.src = window.URL.createObjectURL(stream); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* request access to just the user's camera */ | |
{ video: true } | |
/* request access to the user's microphone and camera, with a preferred resolution of 1280X720 */ | |
{ | |
audio: true, | |
video: { width: 1280, height: 720 } | |
} | |
/* request access to the user's microphone and camera, with a minimum resolution of 1280X720 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.mediaDevices.getUserMedia(mediaType) | |
.then(function(stream) { | |
/* on success, manipulate the stream */ | |
}) | |
.catch(function(err) { | |
/* on error, handle the error */ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resolveLater() { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve('finish'); | |
}, 2000); | |
}); | |
} | |
async function asyncCall() { | |
console.log('let'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async fetchFromBackEnd(){ | |
this.notes = await fetch("http://localhost:3000/api/v1/notes").then(response => response.json()) | |
// render sidebar notes | |
for (const note of this.notes) { | |
let newNote = new Note({title: note.title, body: note.body, id: note.id}); | |
newNote.createSidebarDiv() | |
} | |
// sidebar eventlistener (show note) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetchFromBackEnd(){ | |
fetch("http://localhost:3000/api/v1/notes") | |
.then(response => response.json()) | |
.then(notes => { | |
// render sidebar notes | |
for (const note of notes) { | |
let newNote = new Note({title: note.title, body: note.body, id: note.id}); | |
newNote.createSidebarDiv() | |
} |