# `Dala.Camera`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/camera.ex#L1)

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.

# `capture_photo`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

Stop the active camera preview session.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
