Dala.Camera (dala v0.0.1)

Copy Markdown View Source

Native camera capture for photos and videos.

Requires :camera permission (and :microphone for video).

Opens the native OS camera UI. Results arrive as:

handle_info({:camera, :photo, %{path: path, width: w, height: h}}, socket)
handle_info({:camera, :video, %{path: path, duration: seconds}},   socket)
handle_info({:camera, :cancelled},                                   socket)

The path is a local temp file. Copy it elsewhere before the next capture.

iOS: UIImagePickerController. Android: TakePicture / CaptureVideo activity contracts.

Summary

Functions

Open the camera to capture a photo.

Open the camera to record a video.

Start a live camera preview session. Pair with a :camera_preview component in your render tree to display the feed.

Stop the active camera preview session.

Functions

capture_photo(socket, opts \\ [])

@spec capture_photo(
  Dala.Socket.t(),
  keyword()
) :: Dala.Socket.t()

Open the camera to capture a photo.

Options:

  • quality: :high | :medium | :low (default :high) — JPEG compression level

capture_video(socket, opts \\ [])

@spec capture_video(
  Dala.Socket.t(),
  keyword()
) :: Dala.Socket.t()

Open the camera to record a video.

Options:

  • max_duration: integer — maximum clip length in seconds (default 60)

start_preview(socket, opts \\ [])

@spec start_preview(
  Dala.Socket.t(),
  keyword()
) :: Dala.Socket.t()

Start a live camera preview session. Pair with a :camera_preview component in your render tree to display the feed.

Options:

  • facing: :back | :front (default :back)

stop_preview(socket)

@spec stop_preview(Dala.Socket.t()) :: Dala.Socket.t()

Stop the active camera preview session.