通过HTML5或JavaScript启动Android手机前置摄像头 [英] Launch Android phone front camera by HTML5 or JavaScript

查看:1166
本文介绍了通过HTML5或JavaScript启动Android手机前置摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个网络应用程序,该应用程序应该使用Android(版本4.0+)在手机中打开前置摄像头,并且在拍摄照片之后,应用程序应该将捕获的图像上传到我自己的服务器。

I am building a web app which should open the front camera in the phone with Android (version 4.0+) and after taking the picture the app should upload captured image to my own server.

那么可以通过任何HTML5标签或JavaScript代码启动Android手机的前置摄像头吗?

So is it possible to launch Android phone's front camera by any HTML5 tag or JavaScript code?

我知道后置摄像头可以用这个启动tag:

I know that rear camera is possible to launch with this tag:

<input type="file" accept="image/*;capture=camera">

但前置摄像头怎么样?此外,是否可以使用HTML5网络应用程序将固定大小的焦点框架添加到摄像机视图?

But how about front camera? Furthermore, is it possible to add fixed size focus frame to the camera view by using HTML5 web app?

为清晰起见:Web应用程序就是我个案中的网站。它不是用PhoneGap或类似的东西编写的任何Android应用程序。

For clarity: Web app is simply the website in my case. It is not any Android app written with PhoneGap or something like that.

推荐答案


使用没有使用PhoneGap或Android Native代码的设备相机

据我了解,您不希望使用PhoneGap移动网站,但你想使用原生相机选项。

As per I understand you don't want to use PhoneGap for the mobile website but you want to use the native camera option.

在这种情况下我可以建议你可以使用 Bridgeit 可以帮助您访问本机摄像头选项。单击链接以检查演示。

In this scenario what I can suggest is you can use Bridgeit which can help you to access the native camera option. Click on the link to check for the demo.

使用起来非常简单。您需要在HTML页面中添加.js文件并调用camera方法以访问设备的本机摄像头选项。

It is very simple to use. You need to add a .js file in your HTML page and call the camera method to access the native camera option of the device.

示例代码:

使用HTML标头中的Bridgeit.js。 ..

Use the Bridgeit.js in the HTML header...

<script type="text/javascript" src="http://api.bridgeit.mobi/bridgeit/bridgeit.js"></script>

之后您可以使用以下代码调用设备相机:

after that you can call the device camera using the following code:

bridgeit.camera( 'myId', callback, {postURL: '/upload'});

欲了解更多详情,请点击 Bridgeit

For more detail click on Bridgeit.

这篇关于通过HTML5或JavaScript启动Android手机前置摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆