Get started with webrtc-adapter CDN
BSD-3-Clause licensed
Webrtc-adapter is a library simplifying WebRTC implementation by providing polyfills for older browsers.
Tags:- WebRTC
- PeerConnection
- RTCPeerConnection
- getUserMedia
- Chrome
- Chromium
- Firefox
- Edge
- Adapter
- Shim
Stable version
Copied!
How to start using webrtc-adapter CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with webrtc-adapter CDN - cdnhub.io</title>
<style>
#localVideo, #remoteVideo { width: 100%; height: 100%; border: 1px solid black; }
</style>
</head>
<body>
<video id="localVideo" autoplay muted></video>
<video id="remoteVideo" autoplay></video>
<script src="https://cdn.cdnhub.io/webrtc-adapter/8.2.3/adapter.js"></script>
<script>
const localVideo = document.getElementById('localVideo');
const remoteVideo = document.getElementById('remoteVideo');
const localStream = async () => {
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
localVideo.srcObject = stream;
} catch (error) {
console.error('Error accessing media devices.', error);
}
};
localStream();
const configuration = { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] };
const pc = new RTCPeerConnection(configuration);
pc.onicecandidate = (event) => {
if (event.candidate) {
// Send the candidate to the remote peer
}
};
pc.onaddstream = (event) => {
remoteVideo.srcObject = event.stream;
};
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then((stream) => {
localVideo.srcObject = stream;
pc.addStream(stream);
})
.catch((error) => {
console.error('Error accessing media devices.', error);
});
pc.createOffer()
.then((offer) => {
return pc.setLocalDescription(offer);
})
.then(() => {
// Send the offer to the remote peer
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
2.0.2
2.0.3
2.0.4
2.0.5
2.0.6
2.0.7
2.0.8
2.1.0
3.0.0
3.0.1
3.1.0
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
3.1.6
3.1.7
3.2.0
3.3.0
3.3.1
3.3.2
3.3.3
3.3.4
3.4.0
3.4.1
3.4.2
3.4.3
3.4.3-fippo
3.4.4
4.0.0
4.0.1
4.0.2
4.1.0
4.1.1
4.2.0
4.2.1
4.2.2
4.2.2-no-sandbox
5.0.0
5.0.1
5.0.2
5.0.3
5.0.4
5.0.5
5.0.6
6.0.0
6.0.1
6.0.2
6.0.3
6.0.4
6.1.0
6.1.1
6.1.2
6.1.3
6.1.4
6.1.5
6.2.0
6.2.1
6.3.0
6.3.1
6.3.2
6.4.0
6.4.1
6.4.2
6.4.3
6.4.4
6.4.5
6.4.6
6.4.7
6.4.8
7.0.0
7.0.1
7.1.0
7.1.1
7.2.0
7.2.1
7.2.2
7.2.3
7.2.4
7.2.5
7.2.6
7.2.7
7.2.8
7.2.9
7.3.0
7.4.0
7.5.0
7.5.1
7.6.0
7.6.1
7.6.2
7.6.3
7.6.4
7.7.0
7.7.1
8.0.0
8.1.0
8.1.1
8.1.2
8.2.0
8.2.1
8.2.2
8.2.3
9.0.0
*** 9.0.1
zv4.1.1