Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Cli</title>
- <script src='webrtc.js'></script>
- </head>
- <body>
- <div id='status'></div>
- <div id='loading'>
- <button id='boton'>Empezar</button>
- </div>
- <div id='screenVid'>
- <video id='video' autoplay></video>
- </div>
- <div id='console'>
- <p>Consola:</p>
- </div>
- </body>
- <script>
- var wrtc = new WebRTC('player');
- var status = document.getElementById('status');
- var loading = document.getElementById('loading');
- var screenvid = document.getElementById('screenvid');
- var video = document.getElementById('video');
- var boton = document.getElementById('boton');
- /* Empieza */
- wrtc.connect('ws://127.0.0.1:8080');
- function print_status(msg) {
- status.innerHTML = msg;
- }
- function make_invisible(obj) {
- obj.style.display = 'none';
- }
- function make_visible(obj) {
- obj.style.display = 'block';
- }
- document.addEventListener('Event', function(eve) {
- switch (eve.eventType) {
- case 'p2pConnectionReady':
- make_invisible(loading);
- make_visible(video);
- print_status('Conexion p2p realizada');
- break;
- case 'streamAdded':
- video.src = URL.createObjectURL(wrtc.getOtherStream());
- print_status('AƱadido stream de player');
- break;
- case 'failedGetUserMedia':
- print_status('Fallo al conseguir los medios');
- break;
- case 'deniedByUser':
- print_status('El usuario ha denegado el acceso');
- break;
- }
- });
- boton.addEventListener('click', function(e) {
- e.preventDefault();
- wrtc.getMedia({audio: true, video: true}, function(stream) {
- console.log('media');
- video.src = URL.createObjectURL(stream);
- wrtc.producer();
- });
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement