html2app • JS Bridge
    Preparing search index...

    Variable CameraConst

    Camera: {
        takePhoto(): Promise<MessageResponse<{ file: PickedFile | null }>>;
        recordVideo(
            options?: { maxDurationSeconds?: number },
        ): Promise<MessageResponse<{ file: PickedFile | null }>>;
    } = ...

    Camera plugin for taking photos and recording videos with the device camera.

    Type Declaration

    • takePhoto: function
    • recordVideo: function
      • Open the camera app to record a video.

        Parameters

        • options: { maxDurationSeconds?: number } = {}
          • OptionalmaxDurationSeconds?: number

            Optional maximum length in seconds. Must be a positive integer.

        Returns Promise<MessageResponse<{ file: PickedFile | null }>>

        The video as a PickedFile, or file: null if the user cancels. An error if maxDurationSeconds is not a positive integer.

    Android only for now. Requires the camera plugin to be enabled in the app configuration.

    • The device camera app opens, and the result is returned as a PickedFile with a localhost URL. Use it in <img src> or <video src>.
    • If the user cancels, the call still succeeds, with file: null.
    • Captured files are stored in the app cache. They are deleted when the local server starts or closes, so save a file with FileSaver.saveUrl if you need to keep it.
    import { Camera } from '@yandeu/js-bridge/lib/plugins/camera.js'

    const res = await Camera.takePhoto()
    if (res.ok && res.payload.file) img.src = res.payload.file.url