SoundJS

SoundJS  0.2.0

SoundJS > SoundJS > SoundInstance
Search:
 
Filters

Class SoundInstance

Sound Instances are created when any calls to SoundJS.play() are made. The instances are returned by the active plugin for control by the user. Users can control audio directly through the instance.

Constructor

SoundInstance ( src )
Parameters:
src <String> The path to the sound

Properties

owner - HTMLAudioPlugin

The plugin that created the instance
Default Value: null

playState - String

The play state of the sound. Play states are defined as constants on SoundJS
Default Value: null

src - String

The source of the sound.
Default Value: null

uniqueId - String | Number

The unique ID of the instance
Default Value: -1

Methods

getDuration

Number getDuration ( )
Get the duration of the sound instance.
Returns: Number
The duration of the sound instance in milliseconds.

getPan

Number getPan ( )
Get the pan of a sound instance. Note that this does not work in HTML audio.
Returns: Number
The value of the pan between -1 (left) and 1 (right).

getPosition

Number getPosition ( )
Get the position of the playhead in the sound instance.
Returns: Number
The position of the playhead in milliseconds.

getVolume

getVolume ( value )
Get the volume of the sound, not including how the master volume has affected it.
Parameters:
value <object>

mute

Boolean mute ( isMuted )
Mute the sound.
Parameters:
isMuted <Boolean> If the sound should be muted or not.
Returns: Boolean
If the mute call succeeds.

pause

Boolean pause ( )
Pause the instance.
Returns: Boolean
If the pause call succeeds.

play

void play ( interrupt , delay , offset , loop , volume , pan )
Play an instance. This API is only used to play an instance after it has been stopped or interrupted.`
Parameters:
interrupt <String> How this sound interrupts other instances with the same source. Interrupt values are defined as constants on SoundJS.
delay <Number> The delay in milliseconds before the sound starts
offset <Number> How far into the sound to begin playback.
loop <Number> The number of times to loop the audio. Use -1 for infinite loops.
volume <Number> The volume of the sound between 0 and 1.
pan <Number> The pan of the sound between -1 and 1. Note that pan does not work for HTML Audio.
Returns: void

resume

Boolean resume ( )
Resume a sound instance that has been paused.
Returns: Boolean
If the resume call succeeds.

setPan

Number setPan ( value )
Set the pan of a sound instance. Note that this does not work in HTML audio.
Parameters:
value <Number> The pan value between -1 (left) and 1 (right).
Returns: Number
If the setPan call succeeds.

setPosition

void setPosition ( value )
Set the position of the playhead in the sound instance.
Parameters:
value <Number> The position of the playhead in milliseconds.
Returns: void

setVolume

Boolean setVolume ( value )
Set the volume of the sound instance.
Parameters:
value <object>
Returns: Boolean
If the setVolume call succeeds.

stop

Boolean stop ( )
Stop a sound instance.
Returns: Boolean
If the stop call succeeds.

Events

onComplete

onComplete ( )
The callback that is fired when a sound has completed playback

onLoop

onLoop ( )
The callback that is fired when a sound has completed playback, but has loops remaining.

onPlayFailed

onPlayFailed ( )
The callback that is fired when a sound has failed to start.

onPlayInterrupted

onPlayInterrupted ( )
The callback that is fired when a sound has been interrupted.

onReady

onReady ( )
The callback that is fired when a sound is ready to play.