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