getUserMedia API don't ask the permission and go to the error callback (Opera)

215 views
Skip to first unread message

Ludo

unread,
Feb 29, 2012, 9:41:28 AM2/29/12
to discuss...@googlegroups.com
Hi,

I am making some tests with the getUserMedia API, with Opera.

My browser detect the getUserMedia API but i can't get the stream, i don't know why ! It works on this page.

i made this code:
<html>
<head></head>
<body>
<form enctype="multipart/form-data" method="post">
  <video id="screen" autoplay></video>
<script>
if (navigator.getUserMedia)
{
  navigator.getUserMedia({audio: true, video: true}, success, error);
 
  function success(stream)
  {
        alert('OK');
    var video = document.getElementsById('screen');
    video.src = stream;
  }

  function error(data)
  {
    alert('fail: '+data.code);
  }
}
else
{
  alert('no supported !');
}
</script>
</form>
</body>
</html>

It prints "fail: 1", which is, according to the documentation a PERMISSION_DENIED, ideed, my browser doesn't ask me any permission, maybe it's because i accepted the premission from the website i visited for the test (the link i print above).

Thanks !

Vikas Marwaha

unread,
Mar 8, 2012, 2:53:22 PM3/8/12
to discuss-webrtc
Hi,

I tested on opera labs version 12.00 alpha build 1232 for Win7 and the
below code works for me. Can you test the code below:-

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script type="text/javascript">

function gotStreamFailed(error) {
alert("Failed to get access to local media. Error: " + error.code +
".");
}


function enableCamera() {
alert("enableCamera called");
navigator.getUserMedia({audio:true, video: true}, function(stream)
{
// Replace the source of the video element with the
stream from the camera
document.getElementById("localView").src = stream;
}, gotStreamFailed);
}

window.onload = enableCamera;

</script>
</head>

<body>
<table>
<tr>
<th align="left">Local Preview</th>
</tr>
<tr>
<td> <video width="320" height="240" id="localView"
autoplay="autoplay"></video> </td>
</tr>
<tr>
<td align="left">
</td>
<td>&nbsp;</td>
</tr>
</table>

</body>
</html>

Thanks,
Vikas

On Feb 29, 6:41 am, Ludo <ludovic....@gmail.com> wrote:
> Hi,
>
> I am making some tests with the getUserMedia API, with Opera.
>
> My browser detect the getUserMedia API but i can't get the stream, i don't
> know why ! It works on this page<http://people.opera.com/danield/html5/explode/>
> .
Reply all
Reply to author
Forward
0 new messages