AudioModule


The AudioModule class enables sound effects.

Example

const Audio = require('Audio');
const TouchGestures = require('TouchGestures');

const playbackController = Audio.getPlaybackController('playbackController');
playbackController.loop();

let soundOn = true;

TouchGestures.onTap().subscribe(function() {
  if (!soundOn) {
    playbackController.play();
  } else {
    playbackController.stop();
  }
  soundOn = !soundOn;
});

Properties

This class exposes no properties.

Methods

MethodDescription

getPlaybackController

getPlaybackController(name: String): PlaybackController Get a playback controller from assets by name.

play

play(audioSource: AudioSource): void

Creates a new playing instance of the sound associated with this AudioSource.

stopAll

stopAll(audioSource: AudioSource): void

Stops all playing instances of this AudioSource.

Classes

ClassDescription

PlaybackController

The PlaybackController class allows to control playback of audio