Sound


super: Object

Provides playback of audio data from a file, an url or memory. A Sound object is usually a representation of an audio asset.

Events

  • Load() This event is called when the object becames available in the current runtime system.

  • Completed() Handle this event if you want to perform some operations when audio resource finished playing.

  • OnError() Handle this event if you want to take any action in case of error.

  • Unload() This event is called when the object has been removed from the current runtime system (but not yet deallocated).

Properties

  • var isPlaying: Bool A Bool value that indicates whether the audio player is playing. (read-only)

  • var channels: Int The number of audio channels in the sound associated with the audio player. (read-only)

  • var duration: Float Returns the total duration, in seconds, of the sound associated with the audio player. (read-only)

  • var pan: Float The audio player’s stereo pan position. By setting this property you can position a sound in the stereo field. A value of –1.0 is full left, 0.0 is center, and 1.0 is full right.

  • var volume: Float The playback volume for the audio player, ranging from 0.0 through 1.0 on a linear scale.

  • var time: Float The playback point, in seconds, within the timeline of the sound associated with the audio player. If the sound is playing, currentTime is the offset of the current playback position, measured in seconds from the start of the sound. If the sound is not playing, currentTime is the offset of where playing starts upon calling the play method, measured in seconds from the start of the sound.

By setting this property you can seek to a specific point in a sound file or implement audio fast-forward and rewind functions.

  • var objectName: String The name of the object.

Class Methods

  • func open(srcfile: Object): Object Initializes and returns the Sound object with the content of the source file. The source file can be an URL or a File object.

Constructors

  • func Sound(nameOrURL: Object) Creates and initializes a new sound resource.

  • func Sound(nameOrURL: Object, globalInstance: Bool) Creates and initializes a new sound resource.

Methods

  • func play(): Bool Plays a sound asynchronously.

  • func pause() Pause a sound.

  • func resume() Resume a sound.

  • func stop() Stop a sound.