Hi Tribolet,
Thanks for the response. But still after the prefix also it is not
working.
I have used the getUserMedia API for video capturing in opera browser
and is working but when i try to do the same with audio (capturing
from microphone) ,it doesnt work.
This code is working fine for capturing video from webcam in opera
browser but audio part is not working.
<!-- HTML code -->
<!DOCTYPE html>
<html>
<body>
<video id="sourcevid" autoplay>Put your fallback message here.</video>
<audio id="sourceaid" autoplay >Put your fallback message here.</
audio>
/* JavaScript code */
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function() {
// Assign the <video> element to a variable
var video = document.getElementById('sourcevid');
var audio = document.getElementById('sourceaid');
// Replace the source of the video element with the stream from
the camera
if (navigator.getUserMedia) {
navigator.getUserMedia('audio,video', successCallback,
errorCallback);
// Below is the latest syntax. Using the old syntax for the
time being for backwards compatibility.
// navigator.getUserMedia({video: true}, successCallback,
errorCallback);
function successCallback(stream) {
video.src = stream;
audio.src = stream;
//var rate = audio.mozSampleRate;
//var channels = audio.mozChannels;
//var length = audio.mozFrameBufferLength;
//audio.src = stream;
}
function errorCallback(error) {
console.error('An error occurred: [CODE ' + error.code +
']');
return;
}
} else {
console.log('Native web camera streaming (getUserMedia) is not
supported in this browser.');
return;
}
}, false);
</script>
</body>
</html>
Suggest something.
Thanks and Regards,
Rupesh
On Feb 22, 5:20 pm, Tribolet Luc <
luc.tribo...@gmail.com> wrote:
> You use the sample code given on the specification w3c page and it's
> still a draft.
>
> Therefore you have to use prefix on method which depend the browser
> you're using.
>
> To be able to capture media from device on chrome/chromium you have to
> use the method webkitGetUserMedia() like :
>
> navigator..webkitGetUserMedia("audio", gotStream, noStream);
>
> Regards
>
> Luc
>
> On 22 fév, 13:01, Rupesh Kumar <
rupeshs...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I tried with the the given code for theaudiocapture from themicrophone
> > in many browsers like(opera,chrome canary,chromium-beta n others also)...
> > <html>
> > <body>
> > <input type="button" value="?" onclick="msgRecord()" id="recBtn">
> > <input type="button" value="?" onclick="msgStop()" id="stopBtn" disabled>
> > <p id="status">To start recording, press the ? button.</p>
> > <script>
> > var recBtn = document.getElementById('recBtn');
> > var stopBtn = document.getElementById('stopBtn');
> > function report(s) {
> > document.getElementById('status').textContent = s;
> > }
> > function msgRecord() {
> > report('Attempting to accessmicrophone...');
> > report('Could not obtain access to yourmicrophone. To try again, press
> > the ? button.');
> > recBtn.disabled = false;
> > }
> > </script>
>
> > </body>
> > </html>
>
> > But it is not working.
> > Is it possible to captureaudiofrommicrophonein HTML5 by using