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