Back to Introduction
Up to Table of Contents
Ahead to Browser Object

Audio Object

Audio objects play . au files that are in the mu law file format. Use the Audio tool to draw Audio objects. The tool appears as follows:

Use the object's Filename property to specify the desired audio file. Use the PlayCount property (set to 1 by default) to specify whether you want to play the file once or infinitely. Use the Play() method to direct the object to play.

If you want the object to play upon creation, make sure that its To Do List contains an item that sets the Play() method for the Create event. In order to play an Audio object, you must save your application and run it.

Note: You can also play the Audio object when a user interacts with another object such as a Push Button. For more information see the subsection on "Audio Object Interactivity."

Audio Object Appearance

When you draw an Audio object it appears as shown in the figure below. However, Audio objects are never visible at runtime.

Playing Audio

The following subsections describe the typical ways to play an Audio object.

Playing Audio via another Object

Often, a user plays an Audio object via another object such as a Push Button or Picture Push Button. As an example, you would set up a button so that its To Do List for a Click event contains an item for the Audio object. The Audio object is directed to play via the Play() method. When the user clicks on the button, the audio plays until it reaches the end of the media or until the object is deleted when another page displays. (If the Audio object is on a background page, the audio continues to play until the background page is deleted.)

Playing Audio when the Page Displays

Audio objects can also be set to play when the page that contains the object displays. Set up the object's To Do List so that a Create event causes the Audio object to play via the Play() method.

Playing Audio when the File Finishes Loading

You can also set the object to play as soon as a sound file has finished loading. Set up the object's To Do List so that a LoadComplete event causes the object to play via the Play() method.

Lesson: Playing Audio

In this lesson, you set the properties of an Audio object so that it plays immediately when the Audio object is created. You'll also include a Graphic object on the page so that there is some visual information in the display.

Important: Make sure to complete every required step in this lesson (and in any other lessons you do later in the manual). Otherwise, the application will not perform as expected. Required steps are preceded with a bullet and the instructions appear bolded.

A completed version of this lesson, called lesn_5, is located in the \Jamba\lessons directory.

Use the Properties tab to set the file you want to play.

Now you'll draw the Audio object.

The object's properties appear as follows:

Use the Properties tab to set the file you want to play.

An Open dialog box appears.

The PlayCount property, which determines the number of times the sound file plays, is set to 1 by default.

Now use the To Do List to set the object to play when it is created.

The default event is Create. Because you want the To Do List action to occur when the object is first created, you'll leave the default as is.

Note that Play() is a method that doesn't require any information in its Value field.