-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.html
34 lines (31 loc) · 905 Bytes
/
index.html
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
<html>
<head>
</head>
<body>
<h1> WebRTC Voicemail </h1>
<button onclick="window.startVoicemail()"> Start Voicemail </button>
<script>
let pc = new RTCPeerConnection()
navigator.mediaDevices.getUserMedia({audio: true})
.then(stream => {
stream.getTracks().forEach(track => {
pc.addTrack(track, stream)
})
pc.createOffer().then(d => pc.setLocalDescription(d))
}).catch(window.alert)
function startVoicemail() {
fetch('/create-voicemail', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(pc.pendingLocalDescription)
})
.then(response => response.json())
.then(sdp => {
pc.setRemoteDescription(sdp).catch(window.alert)
})
}
</script>
</body>
</html>