master
bel 2020-05-10 12:38:34 -06:00
parent 861210c941
commit 71053a1851
1 changed files with 35 additions and 22 deletions

View File

@ -104,7 +104,7 @@ class Entropy {
static local = null;
static pageReady() {
Entropy.local = new Local("video");
Entropy.local = Local.build("video");
}
static start(isCaller) {
@ -166,30 +166,37 @@ class Entropy {
}
class Local {
type = null;
stream = null;
constructor(type) {
this.type = type;
switch (type) {
case "video":
case "audio":
static build(type) {
switch(type) {
case "audio": return new Audio();
case "video": return new Video();
case "text": return new Text();
default: View.error("unknown build", type);
}
}
constructor() {
var constraints = {
video: type == "video",
audio: type == "audio",
video: this.gettype() == "video",
audio: this.gettype() == "audio",
};
if(!navigator.mediaDevices.getUserMedia) {
View.error('Your browser does not support getUserMedia API');
}
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {
if (type == "video") {
if (this.gettype() == "video") {
new Preview('preview', stream);
}
this.stream = stream;
})
.catch(View.error);
}
gettype() {
View.error("not impl");
}
start() {}
@ -198,9 +205,15 @@ class Local {
}
class Audio extends Local {
gettype() {
return "audio";
}
}
class Video extends Local {
gettype() {
return "video";
}
}
class Text extends Local {