| AudioClip |
|
typedict |
| |
An
AudioClip
is an object that can be used to play sound files that have been recorded
in various formats.
Yoix programs interact with audioclips by reading, writing, or executing
the following fields:
| disabled |
An
int
that represents the current state of the audioclip.
A value of
0
means the file represented by
name
exists and can be played, while a value of
1
means
name
was
NULL
or could not be found.
Unfortunately the current implementation does not guarantee that
name
is a legitimate audio file, so a zero value does not mean you
will hear anything when the audioclip is played.
Writing is not allowed and will result in an
invalidaccess
error.
| | name |
A
String
that names the audio file (as a local file or URL) that is represented
by the audioclip.
The named file is the one that will be played the next time the
play
or
loop
built-ins are called with no arguments.
Writing is allowed, but always stops the playing of the current audio file;
name
can also be changed by the
loop
and
play
fields.
| | loop([String path]) |
A
Builtin
that starts a continuous loop that plays the audio file named by
path
or referenced by the audioclip's
name
field when there is no argument.
A nonzero return indicates success, but unfortunately does not mean
the file was a legitimate audio file.
The
path
argument, when supplied, is stored in the audioclip's name field.
| | play([String path]) |
A
Builtin
that starts plays the audio file named by
path
or referenced by the audioclip's
name
field when there is no argument.
A nonzero return indicates success, but unfortunately does not mean
the file was a legitimate audio file.
The
path
argument, when supplied, is stored in the audioclip's name field.
| | stop() |
A
Builtin
that stops the playing of the current audio file.
There is no return value.
|
Unfortunately audioclips require a 1.2 or later version of the Java
Virtual Machine (JVM), otherwise they will be permanently disabled,
and even then they may not play on all platforms.
Windows PCs seem to perform well, but larger systems (e.g., multi-user
UNIX machines) are less predictable.
| |
| Example: |
The program,
import yoix.thread.*;
String SUNSITE = "http://java.sun.com/";
String EXAMPLES = "docs/books/tutorial/sound/example-1dot2/";
AudioClip ac;
ac.loop(SUNSITE + EXAMPLES + "bottle-open.wav");
sleep(5);
ac.play(SUNSITE + EXAMPLES + "spacemusic.au");
sleep(10);
plays a few sounds files that we found on Sun's official Java site.
| | |
| See Also: |
Canvas,
Dialog,
Frame,
Graphics,
Panel,
Window
|
|
Yoix is a registered trademark of AT&T Inc.
|