0
我有一个Web应用程序,在这里使用的解决方案打开了一个摄像头:如何从打开相机返回后检测Web应用程序的简历?
How to access a mobile's camera from a web app?
但是,我怎么可以运行一个回调函数,当我从相机应用程序返回到Web应用程序?
感谢
我有一个Web应用程序,在这里使用的解决方案打开了一个摄像头:如何从打开相机返回后检测Web应用程序的简历?
How to access a mobile's camera from a web app?
但是,我怎么可以运行一个回调函数,当我从相机应用程序返回到Web应用程序?
感谢
你说你会试图模糊/聚焦的方法,但你尝试每https://stackoverflow.com/a/19519701/6004366知名度API?
我写了一个简短的脚本并对它进行了测试,然后进入我的相机然后回来,并记录下它的能见度并重新获得它。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input type="file" accept="image/*" capture="camera">
<ul id="log">
</ul>
<script type="text/javascript">
var vis = (function(){
var stateKey, eventKey, keys = {
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
};
for (stateKey in keys) {
if (stateKey in document) {
eventKey = keys[stateKey];
break;
}
}
return function(c) {
if (c) document.addEventListener(eventKey, c);
return !document[stateKey];
}
})();
vis(function(){
var logitem = vis() ? 'Visible' : 'Not visible';
var loglist = document.getElementById("log");
var node = document.createElement("LI");
var textnode = document.createTextNode(logitem);
node.appendChild(textnode);
loglist.appendChild(node);
});
</script>
</body>
</html>
您可以对窗口使用模糊和焦点事件。请参阅:http://stackoverflow.com/questions/1760250/how-to-tell-if-browser-tab-is-active –
我试过了,但是当我打开相机时它没有启动。 – omega