捕捉前置摄像头 - PhoneGap?

发布于 2025-01-07 04:17:27 字数 196 浏览 4 评论 0原文

如何使用 PhoneGap 从前置摄像头捕获视频?

我在 Phonegaps API 在线文档中找到了这个 navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2}); ,但我没有看到任何有关使用前置摄像头而不是后置摄像头的信息。是否可以?

How to capture video from front-facing camera, using PhoneGap?

I found this navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2}); in Phonegaps API docs online, but I don't see anything about using the front camera instead of rear. Is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淤浪 2025-01-14 04:17:27

我想相机打开后,你可以选择前置摄像头。目前我不认为有默认打开前置摄像头的选项

I think after the camera opens up, u can choose the front camera. Currently i dont think so there is an option to open the front camera by default

长梦不多时 2025-01-14 04:17:27

如果您的智能手机有前后摄像头,当您使用

navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2});

拍摄时,相机将自动通过开关按钮打开。

If your smartphone have front and back camera, when you use

navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2});

capture camera will be opened with switch button automatically.

合久必婚 2025-01-14 04:17:27

自从我有了一个应用程序的想法以来,我今天就在玩 PhoneGap。对于这个想法,我还需要选择前置摄像头作为默认值。在尝试了不同的方法后,我找到了一种解决方法,默认选择前置摄像头[注意:这是一个肮脏的修复,我不知道在没有前置摄像头的设备上会发生什么!]

在 Xcode(或您使用的任何编辑器)中打开 [ProjectName]/plugins/CDVCapture.m 并找到 captureImage 和 captureVideo。这两个函数/命令都有一行表示

pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

在下面添加此行:

pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;

视频和图像捕获都会选择正面打开相机应用程序时默认为相机。然而,用户仍然可以切换相机。

这是一个包含完整 CVDCapture.m 文件的 Pastebin: http://pastebin.com/kkkyiPdn

I was playing around with PhoneGap today since I had an idea for an app. For this idea I needed the front facing camera aswell to be selected as default. After trying different things I found a work around which selected the front facing camera by default [NOTE: this is a dirty fix, I've got no clue what happens on devices without a front facing camera!]

In Xcode (or whatever editor you use) open [ProjectName]/plugins/CDVCapture.m and locate both captureImage and captureVideo. Both functions/commands have a line saying

pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

Add this line below:

pickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;

And both Video and Image capturing will select the front facing camera by default when opening up the camera app. However, the user still has the possibility to switch cameras.

Here's a pastebin with my full CVDCapture.m file: http://pastebin.com/kkkyiPdn

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文