跳过主要内容
返回插件
@capgo/camera-preview
教程
@capgo/camera-preview

相机预览

以可定制控件和捕获功能为界面的实时相机预览

指南

相机预览教程

在设备上测试

下载Capgo应用程序,然后扫描QRcode。

摄像头预览插件预览二维码code

使用 @capgo/camera-preview

摄像头预览插件的主要界面。

安装

bun add @capgo/camera-preview
bunx cap sync

此插件暴露的内容

  • start - 启动摄像头预览。
  • stop - 停止摄像头预览。
  • capture - 从摄像头捕获一张图片。
  • captureSample - 从摄像头预览流中捕获一帧。

示例用法

start

启动摄像头预览。

import { CameraPreview } from '@capgo/camera-preview';

await CameraPreview.start({} as CameraPreviewOptions);

stop

停止摄像头预览。

import { CameraPreview } from '@capgo/camera-preview';

await CameraPreview.stop();

capture

从摄像头中捕获一张图片。

import { CameraPreview } from '@capgo/camera-preview';

await CameraPreview.capture({} as CameraPreviewPictureOptions);

captureSample

从摄像头预览流中捕获一张单帧。

import { CameraPreview } from '@capgo/camera-preview';

await CameraPreview.captureSample({} as CameraSampleOptions);

全局参考

继续使用@capgo/camera-preview

如果您正在使用 使用@capgo/camera-preview 来规划原生媒体和界面行为,连接它与 @capgo/camera-preview For the implementation details in @capgo/camera-preview, 开始使用 For the implementation details in 开始使用, 使用 @capgo/capacitor-live-activities For the native capabilities in 使用 @capgo/capacitor-live-activities, @capgo/capacitor-live-activities For the implementation details in @capgo/capacitor-live-activities, and 使用 @capgo/capacitor-video-player For the native capabilities in 使用 @capgo/capacitor-video-player.