-
Notifications
You must be signed in to change notification settings - Fork 3
/
dimsum.js
57 lines (51 loc) · 1.71 KB
/
dimsum.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This file is just a bunch of methods I use extensively. I called it dimsum
// because is like a said tasty brunch, full of nice and tasty stuff :)
/* global URL */
function makeGetStreamX(width, height, buttonName, gotStreamFunction) {
return function() {
var constraintsWidthXHeight = {
"audio": false,
"video": {
"mandatory": {
"minWidth": width,
"maxWidth": width,
"minHeight": height,
"maxHeight": height,
},
"optional": [{ echoCancellation : false}]
}
};
navigator.webkitGetUserMedia(constraintsWidthXHeight,
gotStreamFunction,
getUserMediaFailedCallback);
document.getElementById(buttonName).disabled = true;
};
}
function createButton(id, text, onClick) {
const button = document.createElement("input");
button.id = id;
button.type = "button";
button.value = text;
button.onclick = onClick;
button.className = "w3-btn-primary w3-teal w3-round";
document.body.appendChild(button);
console.log("Button " + id + " created");
}
function createVideoTag(id, width, height, video_source) {
const videoTag = document.createElement('video');
if (video_source != '')
videoTag.src = URL.createObjectURL(video_source);
videoTag.id = id;
videoTag.width = width;
videoTag.height = height;
videoTag.className = "w3-round w3-border w3-card-4";
document.body.appendChild(videoTag);
videoTag.autoplay = true;
console.log("VideoTag " + id + " created");
}
function getUserMediaFailedCallback(error) {
console.error('User media request denied with error code ' + error.code);
}
function recorderOnStop() {
console.log('recorderOnStop fired');
}