Class Sound
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Sound

public class netscape.application.Sound
    extends java.lang.Object
    implements netscape.util.Codable
{
    /* Constructors
     */
    public Sound();

    /* Methods
     */
    public static Sound soundFromURL(URL);
    public static synchronized Sound soundNamed(String);

    public void decode(Decoder);
    public void describeClassInfo(ClassInfo);
    public boolean doesLoop();
    public void encode(Encoder);
    public void finishDecoding();
    public String name();
    public void play();
    public void setLoops(boolean);
    public void stop();
    public String toString();
}
Object subclass representing a sound. Typically, you retrieve a Sound by name from an 8 bit, µlaw, 8000 Hz, one-channel, Sun ".au" file:
    sound = Sound.soundNamed("MySound.au");

Constructors

.Sound

  public Sound()
Constructs a Sound with no sound data. This method is only useful when decoding.

Methods

.soundNamed

  public static synchronized Sound soundNamed(String soundName)
Returns the Sound named soundName. The application maintains a cache of named Sounds that it checks first. If not located in the cache, this method looks for the specified Sound in the "sounds" direcotry in the same directory as the Application's index.html file. In other words, it constructs the URL
    "codebase"/sounds/soundName
and attempts to load this file. soundName can specify a file name or path, such as "newSounds/MySound.au".

Note: No error will be reported if the specified Sound file does not exist or is the wrong format.

.soundFromURL

  public static Sound soundFromURL(java.net.URL url)
Returns a Sound initialized with data from url.

.name

  public String name()
Returns the Sound's name, if any.

.setLoops

  public void setLoops(boolean flag)
Sets the Sound to automatically replay upon completion, or just play once to completion.

.doesLoop

  public boolean doesLoop()
Returns true if the Sound automatically replays upon completion.
See Also:
setLoops

.play

  public void play()
Plays the Sound.

.stop

  public void stop()
Stops the Sound playback.

.toString

  public String toString()
Returns the Sound's String representation.
Overrides:
toString in class Object

.describeClassInfo

  public void describeClassInfo(ClassInfo info)
Describes the Sound class' coding information.
See Also:
describeClassInfo

.encode

  public void encode(Encoder encoder) throws CodingException
Encodes the Sound. A Sound can only be encoded if it has a name.
See Also:
soundNamed, encode

.decode

  public void decode(Decoder decoder) throws CodingException
Decodes the Sound. A Sound can only be decoded if it has a name.
See Also:
decode

.finishDecoding

  public void finishDecoding() throws CodingException
Finishes the Sound's decoding.
See Also:
finishDecoding

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997