master
wanggang 4 years ago
parent 62ebdee23c
commit d32f072457

@ -10,7 +10,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages> <SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
<Version>0.1.0</Version> <Version>0.1.1</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

@ -15,5 +15,10 @@ namespace PhotoCollector
} }
return null; return null;
} }
public string GetAppPath()
{
return AppContext.BaseDirectory;
}
} }
} }

@ -86,7 +86,7 @@
<hr /> <hr />
<img id="idCard" width="102" height="126" alt="" /> <img id="idCard" width="102" height="126" alt="" />
<script> <script>
var appBasePath = navigator.userAgent.split('|')[1]; var appBasePath = window.chrome.webview.hostObjects.sync.dotnet.GetAppPath();
//window.chrome.webview.postMessage({ command: "setStatus", message: `start at ${appBasePath}` }); //window.chrome.webview.postMessage({ command: "setStatus", message: `start at ${appBasePath}` });
function onIdCardRead(card) { function onIdCardRead(card) {
@ -213,30 +213,33 @@
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');
context.drawImage(video, (video.width - width) / 2, (video.height - height) / 2, width, height, 0, 0, width, height); context.drawImage(video, (video.width - width) / 2, (video.height - height) / 2, width, height, 0, 0, width, height);
}; };
function init() { select.onchange = function (event) {
select.onchange = function (event) { var hdConstraints = {
var hdConstraints = { audio: false,
audio: false, video: {
video: { width: { min: 640, ideal: 1280, max: 1920 },
width: { min: 640, ideal: 1280, max: 1920 }, height: { min: 360, ideal: 720, max: 1080 },
height: { min: 360, ideal: 720, max: 1080 }, deviceId: event.target.value
deviceId: event.target.value }
}
};
navigator.mediaDevices.getUserMedia(hdConstraints).then(function (mediaStream) {
video.srcObject = mediaStream;
video.addEventListener("loadedmetadata", function (e) {
video.width = e.srcElement.videoWidth;
video.height = e.srcElement.videoHeight;
//var wrapper = document.querySelector('.videoWrapper');
//wrapper.style.width = video.width + 'px';
//wrapper.style.height = video.height + 'px';
video.play();
});
}, function (err) {
console.error('getUserMediaErrorCallback')
});
}; };
navigator.mediaDevices.getUserMedia(hdConstraints).then(function (mediaStream) {
video.srcObject = mediaStream;
video.addEventListener("loadedmetadata", function (e) {
video.width = e.srcElement.videoWidth;
video.height = e.srcElement.videoHeight;
//var wrapper = document.querySelector('.videoWrapper');
//wrapper.style.width = video.width + 'px';
//wrapper.style.height = video.height + 'px';
video.play();
});
}, function (err) {
console.error('getUserMediaErrorCallback')
});
};
function init() {
if (video.srcObject&&video.srcObject.active) {
return;
}
navigator.mediaDevices.enumerateDevices() navigator.mediaDevices.enumerateDevices()
.then(function (devices) { .then(function (devices) {
select.innerHTML = ""; select.innerHTML = "";
@ -255,7 +258,8 @@
console.log(err.name + ": " + err.message); console.log(err.name + ": " + err.message);
}); });
} }
init(); setInterval(init, 5000);
//init();
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save