vi studio

Lessons · Building apps · 23 of 36

Sound and video

play, loop, stop_sounds, audio and video.

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)

Every example here runs in Vi Studio: open it in your browser (phones too) and press Start learning on the welcome page. Each code block there has a Try it button that runs it in the phone preview.

More in Building apps

About Vi. Vi is a free, open-source programming language for building real mobile apps. You describe each screen in plain words, and Vi compiles it to React Native (Expo) for Android, iOS and the web. Its editor, Vi Studio, runs on Windows, in any browser and on your phone, with the app running live as you type. Read more about Vi.