Home >Web Front-end >H5 Tutorial >How to use H5 to call the camera

How to use H5 to call the camera

php中世界最好的语言
php中世界最好的语言Original
2018-01-09 10:31:396174browse

This time I will show you how to use H5 to call the camera, and what are the precautions for H5 to call the camera. The following is a practical case, let's take a look.

<!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(&#39;video&#39;);   
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(&#39;Reeeejected!&#39;, e);   
});   
</script>  
<html>

I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

Detailed explanation of vue.js syntax and common instructions

How to count table sum in bootstrap Quantity

How to implement vue.js todolist

The above is the detailed content of How to use H5 to call the camera. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn