blob: 2b4e3d68325819430748144deff796e42069e878 (
plain)
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
|
const internals = {
peers: {},
createAudioElement(source) {
const audioElement = document.createElement("audio");
audioElement.setAttribute("class", "junction-call-audio");
audioElement.autoplay = "autoplay";
// WE WILL NOT LOSE TADA SUPPORT
if (typeof source === "string") {
audioElement.src = source;
} else {
audioElement.srcObject = source;
}
document.querySelector("body").appendChild(audioElement);
return audioElement;
},
};
export default {
add(id, source) {
internals.peers[id] && this.remove(id);
internals.peers[id] = internals.createAudioElement(source);
},
remove(id) {
internals.peers[id] && internals.peers[id].remove();
delete internals.peers[id];
},
count() {
return Object.keys(internals.peers).length;
},
reset() {
internals.peers = {};
document
.querySelectorAll(".junction-call-audio")
.forEach((audioElement) => audioElement.remove());
},
};
|