h5调用摄像头的实现方法
程序员文章站
2023-11-28 22:25:34
下面小编就为大家带来一篇h5调用摄像头的实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧... 16-06-01...
xml/html code复制内容到剪贴板
- <!doctype html>
- <html lang="zh-cn">
- <head>
- <meta charset="utf-8">
- <title>getusermedia实例</title>
- </head>
- <body>
- <video id="video" autoplay><ideo>
- </body>
- <script type="text/javascript">
- var getusermedia = (navigator.getusermedia || navigator.webkitgetusermedia || navigator.mozgetusermedia || navigator.msgetusermedia);
- getusermedia.call(navigator, {
- video: true,
- audio: true
- }, function(localmediastream) {
- var video = document.getelementbyid('video');
- video.src = window.url.createobjecturl(localmediastream);
- video.onloadedmetadata = function(e) {
- console.log("label: " + localmediastream.label);
- console.log("audiotracks" , localmediastream.getaudiotracks());
- console.log("videotracks" , localmediastream.getvideotracks());
- };
- }, function(e) {
- console.log('reeeejected!', e);
- });
- </script>
- <html>
以上这篇h5调用摄像头的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。