This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>WebRTC with SkylinkJS</title> | |
| <script src="//cdn.temasys.com.sg/skylink/skylinkjs/0.5.x/skylink.complete.min.js"></script> | |
| </head> | |
| <body> | |
| <video id="myvideo" style="transform: rotateY(-180deg);" autoplay muted></video> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var skylink = new Skylink(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| skylink.on('peerJoined', function(peerId, peerInfo, isSelf) { | |
| if(isSelf) return; // We already have a video element for our video and don't need to create a new one. | |
| var vid = document.createElement('video'); | |
| vid.autoplay = true; | |
| vid.muted = true; // Added to avoid feedback when testing locally | |
| vid.id = peerId; | |
| document.body.appendChild(vid); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| skylink.on('incomingStream', function(peerId, stream, isSelf) { | |
| if(isSelf) return; | |
| var vid = document.getElementById(peerId); | |
| attachMediaStream(vid, stream); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| skylink.on('peerLeft', function(peerId, peerInfo, isSelf) { | |
| var vid = document.getElementById(peerId); | |
| document.body.removeChild(vid); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| skylink.on('mediaAccessSuccess', function(stream) { | |
| var vid = document.getElementById('myvideo'); | |
| attachMediaStream(vid, stream); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| skylink.init({ | |
| apiKey: 'Your App key', | |
| defaultRoom: 'Pick a room name' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| skylink.joinRoom({ | |
| audio: true, | |
| video: true | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Font imports */ | |
| @import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;700&display=swap'); | |
| @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap'); | |
| /* Base styles */ | |
| body { | |
| font-family: 'Roboto Slab', 'Helvetica Neue', 'Segoe UI', 'Arial', sans-serif !important; | |
| font-size: 1rem !important; | |
| line-height: 1.6 !important; | |
| color: #333333 !important; |