-1

I am building a software that needs to access user video through browser for which I am using WebRTC.

In my working directory there exists: package.json

 {
  "name": "intro-webrtc",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
  "express": "4.x",
  "ejs": "2.x"
   }
 }

server.js

var express = require('express');
var app = express() ;
console.log('server started');

app.get('/',function(req,res){

res.render('index.ejs') ;
})

app.listen(3000)

view/index.ejs

<!doctype html>
<html lang="en">
<head> 
<title> Introduction to WebRTC </title>
</head>
<body> 
<video autoplay></video>

<script> 
 navigator.getUserMedia = navigator.getUserMedia  ||      
 navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

var constraints = {audio: true, video: true}
var videoArea = document.querySelector{"video"};

navigator.getUserMedia(constraints, onSuccess, onError);

function onSuccess(stream) {
console.log("Sucess! We have a stream!");
videoArea.src = window.URL.createObjectURL(stream);
videoArea.play() ;

}

function onError(error) {

console.log("Error with getUserMedia: ", error);
 }

</script> 
</body>
</html>

When trying to access http://localhost:3000/ , the page appears NOT to be asking for microphone or video access and therefore I am not capturing user's media. I use Google Chrome. Can you help me and tell me where the problem is and it could be fixed?

Thanks in advance.

YAS
  • 303
  • 4
  • 15

1 Answers1

0

You have used wrong brackets in a line of your JS code, you need to replace the following line:

var videoArea = document.querySelector{"video"};

by:

var videoArea = document.querySelector("video");

Javier Conde
  • 2,553
  • 17
  • 25
  • Thank you very much. My mistake. The problem was solved and I can capture user's video now. – YAS Nov 04 '15 at 21:19