# RCWeb Random Video

**Random Video** turns any RCWeb display into a full-screen sequence of 80 popular Pexels videos. The viewer fetches a fresh batch from `GET https://api.pexels.com/v1/videos/popular?per_page=80`, chooses playable MP4 files, and advances to the next video when the current one ends.

## What it shows

- Full-bleed muted Pexels video playback
- Poster frame while each video loads
- Countdown timer, sequence counter, and linked attribution
- Required linked attribution in the form: Video by Photographer Name on Pexels
- QR code linking to the companion **random-video-c** phone control

Tap the display to pause or resume, swipe to move between videos, or use the phone control.

## How it talks to the controller

The viewer is authoritative. It owns the loaded video list, the active index, and the play state, then exposes a small public API on `window.randomVideo`:

```text
randomVideo.next()
randomVideo.prev()
randomVideo.goto(index)
randomVideo.play()
randomVideo.pause()
randomVideo.toggle()
randomVideo.requestState(clientId)
```

Whenever the video changes or play/pause toggles, the viewer pushes a snapshot to every `random-video-c` client in the room with:

```javascript
rc.sendFunctionCall("random-video-c", "randomVideoControl.receiveState", snapshot);
```

## Browser support

Written in ES5 with `XMLHttpRequest`, HTML5 video playback, and conservative responsive CSS. The viewer includes a lean-paint path for older signage browsers that strips expensive effects.

## URL

`/random-video/?r=<room>`
