-
Notifications
You must be signed in to change notification settings - Fork 1
/
daily.js
73 lines (65 loc) · 1.67 KB
/
daily.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
let callFrame;
window.addEventListener("DOMContentLoaded", () => {
initCall();
});
function initCall() {
const container = document.getElementById("container");
const url = new URL("./backgroundButton.png", document.baseURI);
url.protocol = "bg";
callFrame = DailyIframe.createFrame(container, {
showLeaveButton: true,
iframeStyle: {
position: "fixed",
width: "calc(100% - 1rem)",
height: "calc(100% - 1rem)",
},
// Specify a custom button for background controls
customTrayButtons: {
backgrounds: {
iconPath: url.href,
label: "Background",
tooltip: "Set Custom Background",
},
},
})
.on("nonfatal-error", (e) => {
console.warn("nonfatal error:", e);
})
.on("left-meeting", () => {
initCall();
})
.on("custom-button-click", (ev) => {
// If the event is triggered by clicking
// our background button, show the
// background selection window
if (ev.button_id === "backgrounds") {
api.tryEnableBackgrounds();
}
});
// TODO: Replace the following URL with your own room URL.
callFrame.join({ url: "https://<your-domain>.daily.co/<room-name>" });
}
window.addEventListener("set-background", (ev) => {
const data = ev.detail;
let imgPath = data.imgPath;
imgPath = "bg://" + imgPath;
callFrame.updateInputSettings({
video: {
processor: {
type: "background-image",
config: {
source: imgPath,
},
},
},
});
});
window.addEventListener("reset-background", (ev) => {
callFrame.updateInputSettings({
video: {
processor: {
type: "none",
},
},
});
});