@yoda/audio~ AudioManager

new AudioManager()

Members

(static) STREAM_AUDIO :Number

Used to identify the volume of audio streams for audio.

(static) STREAM_TTS :Number

Used to identify the volume of audio streams for tts.

(static) STREAM_RING :Number

Used to identify the volume of audio streams for ring.

(static) STREAM_RING :Number

Used to identify the volume of audio streams for voice call.

(static) STREAM_PLAYBACK :Number

Used to identify the volume of audio streams for multimedia.

(static) STREAM_ALARM :Number

Used to identify the volume of audio streams for alarm.

(static) STREAM_SYSTEM :Number

Used to identify the volume of audio streams for system.

(static) LINEAR_RAMP :module:@yoda/audio~Shaper

The linear curve function for setVolumeShaper.

Methods

(static) setVolume(streamopt, vol)

Set the volume of the given stream.

Parameters:
Name Type Attributes Default Description
stream number <optional>
AudioManager.STREAM_TTS

The stream type.

vol number

The volume to set

Throws:
  • vol must be a number

    Type
    TypeError
  • invalid stream type

    Type
    TypeError
  • stream type readonly

    Type
    Error

(static) setUserLandVolume(vol)

Set the volume to user land streams.

Streams would be set:

  • STREAM_AUDIO
  • STREAM_PLAYBACK
  • STREAM_TTS
  • STREAM_RING
Parameters:
Name Type Description
vol number

The volume to set

Throws:

vol must be a number

Type
TypeError

(static) getVolume(streamopt)

Get the volume of the given stream.

Parameters:
Name Type Attributes Default Description
stream number <optional>
AudioManager.STREAM_AUDIO

The stream type.

Throws:

invalid stream type

Type
TypeError

(static) isMuted() → {Boolean}

Get if the volume is muted.

Returns:
Type:
boolean

if muted.

(static) setMute(val)

Set the volume to be mute or not.

Parameters:
Name Type Description
val boolean

If muted.

(static) setVolumeShaper(shaper)

Set the shaper of the volume.

Parameters:
Name Type Description
shaper module:@yoda/audio~Shaper

The volume shaper function which returns an array with 100 elements.

Throws:
  • shaper function should return an array with 100 elements.

    Type
    Error
  • out of range when set volume shape.

    Type
    RangeError
Example
AudioManager.setVolumeShaper(AudioManager.LINEAR_RAMP)

(static) setPlayingState(Specified, state)

Set the playing state of the given modules.

Parameters:
Name Type Description
Specified string

module name - 'bluetooth', 'multimedia', 'tts'.

state boolean

true: playing, false : stop

(static) getPlayingState(name) → {boolean}

Get the playing state of all or specified modules.

Parameters:
Name Type Description
name string

'bluetooth', 'multimedia', 'tts'.

Throws:

invalid audio name

Type
TypeError
Returns:
Type:
boolean

true: playing, false : stop

(static) getPlayingStatus(streamopt) → {Boolean}

Get the playing status of the given stream.

Parameters:
Name Type Attributes Default Description
stream number <optional>
AudioManager.STREAM_AUDIO

The stream type.

Throws:

invalid stream type

Type
TypeError
Returns:
Type:
boolean

true: stream is connected and playing, false: stream is unconnected.