@yoda/multimedia. Sounder

new Sounder()

The Sounder only supports for playing WAV audio.

var AudioManager = require('@yoda/audio').AudioManager
var Sounder = require('@yoda/multimedia').Sounder

Sounder.once('ready', () => {
  logger.info('wav audio loaded')
})
Sounder.once('error', (err) => {
  if (err) {
    logger.error(err && err.stack)
  }
})
Sounder.init([
  '/opt/media/volume.wav',
  '/opt/media/wakeup.wav'])
Sounder.play(absPath, AudioManager.STREAM_SYSTEM, false, (err)=>{
  logger.error(`playing ${absPath} occurs error ${err && err.stack}`)
})

Methods

(static) init(filenames)

Parameters:
Name Type Description
filenames Array

the file names array which will be preloaded.

Throws:

the sounder player has been ready.

Type
Error

(static) play(filename, streamopt, holdconnectionopt, callback)

Play the given WAV file.

Parameters:
Name Type Attributes Default Description
filename string

specify the file to be played.

stream number <optional>
STREAM_PLAYBACK

the stream type of the player.

holdconnection boolean <optional>
false

whether the current player connection should be hold.

callback callback

playback callback

(static) stop()

Stop the current playing playback.

Events

error

When the sounder player occurs error.

ready

When the sounder player is ready.