A mixin that allows an object to start and stop an audio source, now or in the future, as well as track whether the audio source is currently playing or not.

Consuming object must implement wireConnections and getNodeFrom methods. These methods are included in the Connectable mixin.

Property Summary

Public Properties
public

Whether an audio source is playing or not.

Method Summary

Public Methods
public
play( )

Plays the audio source immediately.

public
playAt(time)

Plays the audio source at the specified moment in time. A "moment in time" is measured in seconds from the moment that the AudioContext was instantiated.

public
playFor(seconds)

Starts playing the audio source immediately, but stops after specified seconds have elapsed.

public
playIn(seconds)

Plays the audio source in specified amount of seconds from "now".

public
playInAndStopAfter(playIn, stopAfter)

Starts playing the audio source after playIn seconds have elapsed, then stops the audio source stopAfter seconds after it started playing.

public
stop( )

Stops the audio source immediately.

public
stopAt(time)

Stops the audio source at the specified "moment in time" relative to the "beginning of time" according to the audioContext.

public
stopIn(seconds)

Stops the audio source after specified seconds have elapsed.

Private Methods
private
_play(time)

The underlying method that backs all of the play methods. Plays sound and sets isPlaying to true at specified time.

private
_stop(stopAt)

The underlying method that backs all of the stop methods. Stops sound and set isPlaying to false at specified time.

Public Properties

Whether an audio source is playing or not.

Public Methods

Plays the audio source immediately.

addon/mixins/playable.js:49

public playAt(time)

Plays the audio source at the specified moment in time. A "moment in time" is measured in seconds from the moment that the AudioContext was instantiated.

Functionally equivalent to _play.

Parameters:

Name Type Attribute Description
time Number

The moment in time (in seconds, relative to the AudioContext's "beginning of time") when the audio source should be played.

addon/mixins/playable.js:80

public playFor(seconds)

Starts playing the audio source immediately, but stops after specified seconds have elapsed.

Parameters:

Name Type Attribute Description
seconds Number

The amount of time after which the audio source is stopped.

addon/mixins/playable.js:67

public playIn(seconds)

Plays the audio source in specified amount of seconds from "now".

Parameters:

Name Type Attribute Description
seconds Number

Number of seconds from "now" that the audio source should be played.

addon/mixins/playable.js:95

public playInAndStopAfter(playIn, stopAfter)

Starts playing the audio source after playIn seconds have elapsed, then stops the audio source stopAfter seconds after it started playing.

Parameters:

Name Type Attribute Description
playIn Number

Number of seconds from "now" that the audio source should play.

stopAfter Number

Number of seconds from when the audio source started playing that the audio source should be stopped.

Stops the audio source immediately.

addon/mixins/playable.js:136

public stopAt(time)

Stops the audio source at the specified "moment in time" relative to the "beginning of time" according to the audioContext.

Functionally equivalent to the _stop method.

Parameters:

Name Type Attribute Description
time Number

The time that the audio source should be stopped.

addon/mixins/playable.js:123

public stopIn(seconds)

Stops the audio source after specified seconds have elapsed.

Parameters:

Name Type Attribute Description
seconds Number

Number of seconds from "now" that the audio source should be stopped.

Private Methods

addon/mixins/playable.js:179

private _play(time)

The underlying method that backs all of the play methods. Plays sound and sets isPlaying to true at specified time.

Functionally equivalent to playAt.

Parameters:

Name Type Attribute Description
time Number

The moment in time (in seconds, relative to the AudioContext's "beginning of time") when the audio source should be played.

addon/mixins/playable.js:151

private _stop(stopAt)

The underlying method that backs all of the stop methods. Stops sound and set isPlaying to false at specified time.

Functionally equivalent to the stopAt method.

Parameters:

Name Type Attribute Description
stopAt Number

The moment in time (in seconds, relative to the AudioContext's "beginning of time") when the audio source should be stopped.