问题描述
我将要开发一个在Windows 8.1平板电脑上运行的应用程序.一个重要的功能是能够单击按钮来访问相机拍摄一些照片.出于多种原因(许可证,跨平台,开发时间:没有使用本机应用程序的原因),理想情况下,我希望将其创建为 Web应用程序而不是本机应用程序.
I am about to develop an application that is to run on Windows 8.1 tablets. An important feature is to be able to click on a button to access the camera to take some pictures. Ideally I would like to create it as a Web application rather than a native application due to a number of reasons (licences, cross-platform, development time: have no experience in native apps, etc.).
我查看了用于从HTML 5捕获图像的选项,并找到了 HTML Media Capture ,使我可以编写:
I have looked at the options for capturing images from HTML 5 and have found HTML Media Capture which allows me to write:
<input type="file" accept="image/*" capture="camera" />
访问摄像机.这在iPad和Android平板电脑上效果很好,但我无法在Windows 8平板电脑上使用.我曾尝试在Windows 8平板电脑上使用Chrome,但仍然没有效果.它所要做的就是打开一个文件对话框,从中可以选择要上传的文件.我想要做的是能够捕获新图像. IE不支持该标准(显然其他浏览器也无法访问设备的摄像头).
To get access to the camera. This works great on iPads and on Android tablets, but I can't get it to work on Windows 8 tablets. I have tried using Chrome on the Windows 8 tablet, but still no effect. All it does is that it opens a file dialog in which I can choose a file to upload. What I want to do is to be able to capture a new image. This standard is not supported by IE (an apparently the other browsers cannot access the device's camera either).
我也偶然发现了媒体捕获和流,主要与显示例如网络摄像头,但可能可用于捕获图像,Chrome和Firefox在其他浏览器中受支持,但Internet Explorer(甚至IE11)仍不支持.不过,这三种浏览器的实现似乎都无法在我的Windows 8.1测试机上运行.如果有人让getUserMedia可以在任何浏览器中的Windows 8平板电脑上运行,我对此很感兴趣.
I have also stumbled across Media Capture and Streams which seems to be mostly related to showing streams from e.g. the web cam, but probably could be used to capture images and is supported by Chrome and Firefox among other browsers, but still not by Internet Explorer (even IE11). None of the three browsers' implementations seem to work on my Windows 8.1 test machine though. If someone has gotten getUserMedia to work on Windows 8 tablets in any browser I'm interested in hearing about it.
无论如何,我的主要问题是:是否可以通过Web应用程序使用HTML5在Windows 8平板电脑上访问相机?我看到的仅有的工作示例依赖于使用Active X的IE原型实现或使用Flash的解决方案.
Anyway, my main question is: Is there any way to access the camera on a Windows 8 tablet using HTML5 from a web application? The only working examples I have seen have relied on a prototype implementation for IE using Active X or solutions that use flash.
我非常希望将其保留在HTML5/javascript中,因为它必须脱机工作(使用HTML5应用程序缓存)
I would very much prefer to keep it in HTML5/javascript as it has to work offline (using HTML5 Application Cache)
推荐答案
我为此解决方案苦苦挣扎,最后找到了一个很好的解决方案.但是只能在Windows存储应用中使用,例如chrome Windows 8模式(chrome设置->在Windows 8模式下重新启动chrome),然后您可以在html中使用普通文件输入标签.当您点击选择文件"时,您会看到下面的图像.然后,您可以选择相机以从相机中添加拍摄图像.
I struggled very much for this solution, at the end I find good a solution. But only can use in windows store apps like chrome windows 8 mode (chrome settings -> relaunch chrome in windows 8 mode) then you can use the normal file input tag in html. when you hit "choose file" u see the image below. Then u can choose camera to add take image from camera.
如果您在列表中看不到相机,则可以在下面安装应用程序.
if you can not see camera in the list, u can install app below.
https://www.microsoft .com/zh-CN/store/apps/Camera-File-Open-Picker/9WZDNCRFJQVN
这篇关于在Windows 8.1平板电脑上的Web应用程序中捕获图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!