# Sound and video

```vi
main player:
  arrange: center
  space_between: 12
  children:
    jingle:
      button: "Play a sound"
      on_tap: play(@ding.mp3)
    music:
      button: "Music on (loops)"
      on_tap: play(@music.mp3, loop)
    quiet:
      button: "Stop all sounds"
      on_tap: stop(sounds)
    clip:
      size: max, auto
      video: @intro.mp4
      loop: true
      volume: 80
    controls:
      arrange: row
      space_between: 8
      children:
        go:
          button: "Play"
          on_tap: play(clip)
        hold:
          button: "Pause"
          on_tap: pause(clip)
        back:
          button: "Stop"
          on_tap: stop(clip)
```

- `play(@x.mp3)` plays a sound once; add `loop` to repeat it. `stop(sounds)` stops them all.
- Vi draws no player. `video:` shows only the frames and `audio:` shows nothing; you make the
  buttons and call `play(box)`, `pause(box)` and `stop(box)` (stop goes back to the start).
- `loop: true` starts it again when it ends; `volume:` goes from 0 (silent) to 100 (full).
- Put the files in the `assets` folder and write them with `@`. Web addresses go in quotes.
