dimanche 18 mai 2014

Contrôler la webcam via HTML5 - Stack Overflow


I want to create a video chat application using HTML5. Is there any recommended frameworks, or solutions that allows to control the camera.


No Flash is allowed!




The experimental support exists.


WebRTC:


http://www.webrtc.org/


Mozilla Camera API:


https://wiki.mozilla.org/Platform/Features/Camera_API


Suitable for demos, but do not expect this to land to Microsoft browsers until 2020.




WebRTC is now supported in Chrome Stable and Firefox and, I believe, is coming to Opera mobile and desktop.


For more information, take a look at the recent Google I/O presentation and slides, which also have information about JavaScript frameworks.




At the moment of writing this the best solution is WebRTC. It is supported in Chrome, Mozilla and Opera, but still unavaialble in Internet Explorer and Safari.


Minimalistic demo.


Index.html


<!DOCTYPE html>
<head>
</head>
<body>
<video></video>
<script src="webcam.js"></script>
</body>

webcam.js


(function () {
navigator.getMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);

navigator.getMedia(
// constraints
{video:true, audio:false},

// success callback
function (mediaStream) {
var video = document.getElementsByTagName('video')[0];
video.src = window.URL.createObjectURL(mediaStream);
video.play();
},
//handle error
function (error) {
console.log(error);
})
})();

Read more here or there



I want to create a video chat application using HTML5. Is there any recommended frameworks, or solutions that allows to control the camera.


No Flash is allowed!



The experimental support exists.


WebRTC:


http://www.webrtc.org/


Mozilla Camera API:


https://wiki.mozilla.org/Platform/Features/Camera_API


Suitable for demos, but do not expect this to land to Microsoft browsers until 2020.



WebRTC is now supported in Chrome Stable and Firefox and, I believe, is coming to Opera mobile and desktop.


For more information, take a look at the recent Google I/O presentation and slides, which also have information about JavaScript frameworks.



At the moment of writing this the best solution is WebRTC. It is supported in Chrome, Mozilla and Opera, but still unavaialble in Internet Explorer and Safari.


Minimalistic demo.


Index.html


<!DOCTYPE html>
<head>
</head>
<body>
<video></video>
<script src="webcam.js"></script>
</body>

webcam.js


(function () {
navigator.getMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);

navigator.getMedia(
// constraints
{video:true, audio:false},

// success callback
function (mediaStream) {
var video = document.getElementsByTagName('video')[0];
video.src = window.URL.createObjectURL(mediaStream);
video.play();
},
//handle error
function (error) {
console.log(error);
})
})();

Read more here or there


0 commentaires:

Enregistrer un commentaire