Class: Sound

(package) rune.media.Sound(channel, resource, uniqueopt)

The Sound class represents a sound that can be played in an audio channel. The class offers an interface for playing a specific sound. It is the sound channel that does the actual playback.

Constructor

(package) new Sound(channel, resource, uniqueopt)

Creates a new Sound object.
Parameters:
Name Type Attributes Default Description
channel rune.media.SoundChannel The channel that "owns" the object.
resource string The name of the audio resource to be used.
unique boolean <optional>
false Whether the object should be unique or shared.
Source:

Members

(readonly) channel :rune.media.SoundChannel

Refers to the audio channel that created the audio object and thus the object is bound to.
Type:
Source:

(readonly) ended :boolean

A boolean value which is true if the media contained in the element has finished playing.
Type:
  • boolean
Source:

loop :boolean

Whether the Sound object should start over when it reaches the end. This can for example be useful for background music.
Type:
  • boolean
Source:

(readonly) name :string

The name of the resource file used as the audio source for the Sound object.
Type:
  • string
Source:

pan :number

Pan represented by a floating point number between -1 (left) and 1 (right). The default value is 0 and distributes the sound evenly between the left and right speakers.
Type:
  • number
Source:

(readonly) paused :boolean

Whether the sound is paused (true) or not (false).
Type:
  • boolean
Source:

(readonly) playbackRate :number

The object's true playback speed, ie the speed relative to the playback speed of the audio channel to which the object is connected.
Type:
  • number
Source:

preservesPitch :boolean

Whether or not the browser should adjust the pitch of the audio to compensate for changes to the playback rate.
Type:
  • boolean
Default Value:
  • true
Source:

rate :number

Sets the rate at which the media is being played back. This is used to implement user controls for fast forward, slow motion, and so forth. The normal playback rate is multiplied by this value to obtain the current rate, so a value of 1.0 indicates normal speed.
Type:
  • number
Default Value:
  • 1.0
Source:

time :number

A double-precision floating-point value indicating the current playback time in seconds; if the media has not started to play and has not been seeked, this value is the media's initial playback time. Setting this value seeks the media to the new time. The time is specified relative to the media's timeline.
Type:
  • number
Source:

(readonly) unique :boolean

Whether the Sound object is unique (true) or shared (false).
Type:
  • boolean
Source:

volume :number

Sound The object's sound volume. Volume is given as a floating point number between 0 (0%) and 1 (100%).
Type:
  • number
Source:

Methods

dispose() → {undefined}

Destroys the audio object and frees allocated memory. The method can be used to remove and destroy Sound objects, but the recommended way to remove (and destroy) a Sound object is via the remove method of the sound channel on which the object was created.
Source:
Returns:
Type
undefined

fade(to, duration) → {undefined}

Adjust the volume of the audio channel to a certain level.
Parameters:
Name Type Description
to number Target volume.
duration number Fade duration.
Source:
Returns:
Type
undefined

pause() → {undefined}

Pause audio playback.
Source:
Returns:
Type
undefined

play(restartopt) → {undefined}

Start audio playback.
Parameters:
Name Type Attributes Default Description
restart boolean <optional>
false Restarts playback (if it is playing).
Source:
Returns:
Type
undefined

resume() → {undefined}

Resumes current audio playback.
Source:
Returns:
Type
undefined

stop() → {undefined}

Stops current audio playback.
Source:
Returns:
Type
undefined