Sound - fapnip/openeos GitHub Wiki

Create and play new mp3

NOTE: Unless the sound being referenced by ID or locator has already been preloaded, all new Sound({...}) expressions, including preloads, must always immediately follow a user input action -- like in your Init Script, in a click listener function, after a paused say, choice, etc. You will have issues if you do not strictly follow this!

Example:

// Create and play new sound
var mySound = new Sound({
  locator: "file:12bpm.mp3",
  loops: 0, // Play until I stop it
})
// Stop sound in 5 seconds.
setTimeout(function() {mySound.stop()}, 5000)

Sound

Constructor Options

id

Optional String. Id to use with Sound.get(id)

locator

Required String. Valid EOS locator for sound file

loops

Required Number. Number of times to play the sound before stopping. 0 = forver.

volume

Optional Number. Volume level between 0 and 1

preload

Optional Function or Boolean.

If set true, will begin preload of audio. Subsequent navigation (pages.goto(...)) will be paused until preload completes.

If set to a function, function will be called when preload completes, and subsequent navigation (pages.goto(...)) will be paused until preload completes.

Constructor Methods

Sound.get(id)

Return sound instance for given id

Instance Methods

destroy()

Remove sound.

stop()

Stop given sound

pause()

Pause given sound

play()

Play given sound

setDoAt(seconds, function)

Execute a function at a given time in the sound.

  • seconds: Required. Floating point value of number of second into the audio playback the function should execute.
  • function: Required. The function you wish to execute the given time.

clearDoAt()

Remove all doAt functions that have been set via setDoAt.

[TODO: Add other methods]