<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width initial-scale=1" />
    <link href="stylesheets/safechat.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="jquery/jquery.min.js"></script>
    <link href="stylesheets/jquery.cssemoticons.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="javascripts/ext/jquery.cssemoticons.js" type="text/javascript"></script>
    <title>WebRTC Test</title>
  </head>

  <body>
    <h1>WebRTC test</h1>
    <div id="status">
    <div id="main">
      <noscript>JavaScript is required!</noscript>
      <video autoplay></video>
    </div>
    <script>
     try {
       var errorCallback = function(e) {
         $('#status').html('ERROR: '+e)
         console.log('ERROR:', e)
       }
       navigator.getUserMedia = navigator.getUserMedia ||
                                navigator.webkitGetUserMedia ||
                                navigator.mozGetUserMedia ||
                                navigator.msGetUserMedia
       if (navigator.getUserMedia) {
         // Not showing vendor prefixes.
         navigator.getUserMedia({
           video: true,
           audio: true,
           facingMode: "user"
         }, function(localMediaStream) {
           var video = document.querySelector('video')
           video.src = window.URL.createObjectURL(localMediaStream)
           
           // Note: onloadedmetadata doesn't fire in Chrome when using it with getUserMedia.
           // See crbug.com/110938.
           video.onloadedmetadata = function(e) {
             // Ready to go. Do some stuff.
           };
         }, errorCallback)
       } else {
         $('#status').html('ERROR: WebRTC not fully supported in this browser')
       }
     } catch (e) {
       $('#status').html('ERROR: '+e.message)
     }
    </script>
  </body>
</html>
