Advertisement
Guest User

client

a guest
Apr 3rd, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.94 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="UTF-8">
  5.     <title>Cli</title>
  6.     <script src='webrtc.js'></script>
  7.   </head>
  8.   <body>
  9.     <div id='status'></div>
  10.     <div id='loading'>
  11.       <button id='boton'>Empezar</button>
  12.     </div>
  13.     <div id='screenVid'>
  14.       <video id='video' autoplay></video>
  15.     </div>
  16.     <div id='console'>
  17.       <p>Consola:</p>
  18.     </div>
  19.   </body>
  20.   <script>
  21.     var wrtc = new WebRTC('player');
  22.  
  23.     var status = document.getElementById('status');
  24.     var loading = document.getElementById('loading');
  25.     var screenvid = document.getElementById('screenvid');
  26.     var video = document.getElementById('video');
  27.     var boton = document.getElementById('boton');
  28.     /* Empieza */
  29.  
  30.     wrtc.connect('ws://127.0.0.1:8080');
  31.  
  32.     function print_status(msg) {
  33.       status.innerHTML = msg;
  34.     }
  35.  
  36.     function make_invisible(obj) {
  37.       obj.style.display = 'none';
  38.     }
  39.     function make_visible(obj) {
  40.       obj.style.display = 'block';
  41.     }
  42.  
  43.     document.addEventListener('Event', function(eve) {
  44.       switch (eve.eventType) {
  45.         case 'p2pConnectionReady':
  46.           make_invisible(loading);
  47.           make_visible(video);
  48.           print_status('Conexion p2p realizada');
  49.           break;
  50.         case 'streamAdded':
  51.           video.src = URL.createObjectURL(wrtc.getOtherStream());
  52.           print_status('AƱadido stream de player');
  53.           break;
  54.         case 'failedGetUserMedia':
  55.           print_status('Fallo al conseguir los medios');
  56.           break;
  57.         case 'deniedByUser':
  58.           print_status('El usuario ha denegado el acceso');
  59.           break;
  60.       }
  61.     });
  62.  
  63.     boton.addEventListener('click', function(e) {
  64.       e.preventDefault();
  65.       wrtc.getMedia({audio: true, video: true}, function(stream) {
  66.         console.log('media');
  67.         video.src = URL.createObjectURL(stream);
  68.         wrtc.producer();
  69.       });
  70.     });
  71.  
  72.   </script>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement