# ctx.camera

Their camera, live, while your app is open — a face in the corner of a clip, a mirror, a scan. Fave1 asks them first and never keeps the video.

camera · card mode · app mode

## Calls

`src/index.ts`

```ts
const cam = await ctx.camera.open({ facing: 'user', width: 720, height: 720 });
bubble.append(cam.video);     // a playing, muted <video playsinline>
// …draw cam.video onto your canvas, record it with MediaRecorder…
cam.stop();                   // or ctx.camera.close() — every camera your app opened
```

| field | What it is | type |
| --- | --- | --- |
| `video` | Already playing and muted. Put it in your panel, or draw it each frame | HTMLVideoElement |
| `stream` | The camera’s stream — for `MediaRecorder` or your own `<video>` | MediaStream |
| `facing` | `user` (front, the default) or `environment` (back) | string |
| `width · height` | What you asked `open()` for — each 64 to 1920, default 720 (outside that range, 720); the browser picks the nearest it has | option |
| `stop()` | Turns this camera off. `ctx.camera.active` tells you if any is still on | function |

Video only — sound is a separate permission, [ctx.mic](https://developers.fave1.com/docs/ctx-mic.md). Need `camera` in your manifest; without it, or with the switch off in Fave1 settings, `open()` rejects with `denied`.

## What the person sees

The first `open()` each time your app opens shows Fave1’s line in your panel: **Let \<your app> use your camera?** When they tap Allow, their browser asks for that site. While a camera is on, a **red dot** sits in your panel’s header. Close your app, close Fave1, or call `stop()`, and the camera goes off.

Call `open()` from a button they pressed — “Add my face” — not at launch.

## When it doesn’t work

| code | What happened · what to do | retry |
| --- | --- | --- |
| `denied` | Not declared, the switch is off, they tapped Not now, or their browser said no (`reason` `not-now` · `browser`). `closed` if `open()` lands after your app closed | no |
| `blocked` | This site doesn’t let any camera run on it (`reason` `site`). Carry on without the face | no |
| `unavailable` | No camera (`reason` `none`), the page isn’t https (`insecure`), or no camera can give that `width` · `height` (`size`) | no |
| `busy` | Another tab or app is using it | later |

## The rule

> **Only through ctx.camera.** The video stays on their page — save it only when they ask (a clip they keep with `ctx.files`, a download), and never send it anywhere else. An app that calls `navigator.mediaDevices.getUserMedia` itself, opens the camera without a tap, or uploads what it sees gets sent back in review.
