Audio

There's a vast library of accessors available. Let's try out accessors for your device's audio and camera. Then we'll build a controller for these.

An accessor may contain other accessors. To instantiate an accessor within another, use instantiate(). Connect the contained accessor to other contained accessors or the container using connect(). The container is called a composite accessor.

The ClipPlayer accessor loads a sound clip from a URL and allows the user to start and stop playback. It has three inputs, start, stop, and clipURL. It has one output, done. We'll create matching start, stop and done inputs and outputs on the container.

connect() takes source object, 'output name', destination object, 'input name' as arguments. The object is omitted for the container.

Try clicking 'react to inputs'. You should hear jazz music. To stop, enter true for the stop input and click 'react to inputs'. The clip is 30 seconds long.

  Camera is up next.