javascript 使用javascript用手机拍照

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28942549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 09:48:23  来源:igfitidea点击:

Take a picture with mobile using javascript

javascriptjqueryimagejquery-mobilemobile

提问by Fortune

I'm looking for a way to take a picture with a phone/tablet on my website, the behavior should be :

我正在寻找一种在我的网站上用手机/平板电脑拍照的方法,行为应该是:

  • The user click a "camera" button.
  • The mobile camera show on.
  • The user take a picture
  • The picture is stored into a variable for a future usage
  • 用户点击“相机”按钮。
  • 手机摄像头亮了。
  • 用户拍照
  • 图片存储在一个变量中以备将来使用

I can't figure out how to do that, i heard that the "phonegap" framework does that but i can't use it since i'm on a MVC c# project. It seems to me that it will be hard to reproduce since i doubt that a web site have the right to launch any app from the mobile.

我不知道如何做到这一点,我听说“phonegap”框架可以做到这一点,但我无法使用它,因为我在 MVC c# 项目中。在我看来,很难复制,因为我怀疑网站是否有权从手机启动任何应用程序。

Is there a way to do that using javascript ? Any solution ?

有没有办法使用 javascript 做到这一点?任何解决方案?

采纳答案by Robert

You can use the HTML5 getUserMedia() API, which is explained in this article: http://www.html5rocks.com/en/tutorials/getusermedia/intro/

您可以使用 HTML5 getUserMedia() API,本文对此进行了说明:http: //www.html5rocks.com/en/tutorials/getusermedia/intro/

Be careful: not all browsers support this (yet). For a detailed list of supporting browsers, take a look at this page: http://caniuse.com/#feat=stream

小心:并非所有浏览器都支持这个(还)。有关支持浏览器的详细列表,请查看此页面:http: //caniuse.com/#feat=stream