Class

io.scalajs.dom.html.phaser

SoundManager

Related Doc: package phaser

Permalink

class SoundManager extends Object

The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files. The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats. There is a good guide to what's supported here: http://hpr.dogphilosophy.net/test/

If you are reloading a Phaser Game on a page that never properly refreshes (such as in an AngularJS project) then you will quickly run out of AudioContext nodes. If this is the case create a global var called PhaserGlobal on the window object before creating the game. The active AudioContext will then be saved to window.PhaserGlobal.audioContext when the Phaser game is destroyed, and re-used when it starts again.

Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio. When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system. The solution is to use a lower encoding rate such as 44100 Hz. Sometimes the audio context will be created with a sampleRate of 48000. If this happens and audio distorts you should re-create the context.

Annotations
@RawJSType() @native() @JSGlobal( "Phaser.SoundManager" )
Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SoundManager
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SoundManager(game: Phaser.Game)

    Permalink

    game

    the reference to the current game instance.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def add(key: String, volume: Int = js.native, loop: Boolean = js.native, connect: Boolean = js.native): Sound

    Permalink

    Adds a new Sound into the SoundManager.

    Adds a new Sound into the SoundManager.

    key

    Asset key for the sound.

    volume

    Default value for the volume.

    loop

    Whether or not the sound will loop.

    connect

    Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio.

    returns

    The new sound instance.

  5. def addSprite(key: String): AudioSprite

    Permalink

    Adds a new AudioSprite into the SoundManager.

    Adds a new AudioSprite into the SoundManager.

    key

    Asset key for the sound.

    returns

    The new AudioSprite instance.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def boot(): Unit

    Permalink

    This member is internal (protected) and may be modified or removed in the future.

    This member is internal (protected) and may be modified or removed in the future. Internal: This member is internal (protected) and may be modified or removed in the future.

    Attributes
    protected
  8. var channels: Int

    Permalink

    The number of audio channels to use in playback (default: 32).

  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. var connectToMaster: Boolean

    Permalink

    Used in conjunction with Sound.externalNode this allows you to stop a Sound node being connected to the SoundManager master gain node (default: true).

  11. var context: AudioContext

    Permalink

    The AudioContext being used for playback.

  12. def decode(key: String, sound: Sound = js.native): Unit

    Permalink

    Decode a sound by its asset key.

    Decode a sound by its asset key.

    key

    Assets key of the sound to be decoded.

    sound

    Optional: Its buffer will be set to decoded data.

  13. def destroy(): Unit

    Permalink

    Stops all the sounds in the game, then destroys them and finally clears up any callbacks.

  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. var game: Phaser.Game

    Permalink

    the reference to the current game instance.

  18. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  19. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  20. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  21. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  22. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  23. var mute: Boolean

    Permalink

    Gets or sets the muted state of the SoundManager.

    Gets or sets the muted state of the SoundManager. This effects all sounds in the game.

  24. var muteOnPause: Boolean

    Permalink

    True if audio been disabled via the PhaserGlobal (useful if you need to use a 3rd party audio library) or the device doesn't support any audio.

  25. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  26. var noAudio: Boolean

    Permalink

    True if audio been disabled via the PhaserGlobal (useful if you need to use a 3rd party audio library) or the device doesn't support any audio.

  27. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  29. var onMute: Signal

    Permalink

    This signal is dispatched when the SoundManager is globally un-muted, either directly via game code or as a result of the game resuming from a pause.

  30. var onSoundDecode: Signal

    Permalink

    The event dispatched when a sound decodes (typically only for mp3 files)

  31. var onUnMute: Signal

    Permalink

    This signal is dispatched when the SoundManager is globally un-muted, either directly via game code or as a result of the game resuming from a pause.

  32. var onVolumeChange: Signal

    Permalink

    This signal is dispatched whenever the global volume changes.

    This signal is dispatched whenever the global volume changes. The new volume is passed as the only parameter to your callback.

  33. def pauseAll(): Unit

    Permalink

    Pauses all the sounds in the game.

  34. def play(key: String, volume: Int = js.native, loop: Boolean = js.native): Sound

    Permalink

    Adds a new Sound into the SoundManager and starts it playing.

    Adds a new Sound into the SoundManager and starts it playing.

    key

    Asset key for the sound.

    volume

    Optional: Default value for the volume (default: 1).

    loop

    Optional: Whether or not the sound will loop (default: false).

    returns

    The new sound instance.

  35. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  36. def remove(sound: Sound): Boolean

    Permalink

    Removes a Sound from the SoundManager.

    Removes a Sound from the SoundManager. The removed Sound is destroyed before removal.

    sound

    The sound object to remove.

    returns

    True if the sound was removed successfully, otherwise false.

  37. def removeByKey(key: String): Int

    Permalink

    Removes all Sounds from the SoundManager that have an asset key matching the given value.

    Removes all Sounds from the SoundManager that have an asset key matching the given value. The removed Sounds are destroyed before removal.

    key

    The key to match when removing sound objects.

    returns

    The number of matching sound objects that were removed.

  38. def resumeAll(): Unit

    Permalink

    Resumes every sound in the game.

  39. def setDecodedCallback(files: |[String, Array[String]], callback: Function, callbackContext: Any): Unit

    Permalink

    This method allows you to give the SoundManager a list of Sound files, or keys, and a callback.

    This method allows you to give the SoundManager a list of Sound files, or keys, and a callback. Once all of the Sound files have finished decoding the callback will be invoked. The amount of time spent decoding depends on the codec used and file size. If all of the files given have already decoded the callback is triggered immediately.

    files

    An array containing either Phaser.Sound objects or their key strings as found in the Phaser.Cache.

    callback

    The callback which will be invoked once all files have finished decoding.

    callbackContext

    The context in which the callback will run.

  40. def setTouchLock(): Unit

    Permalink

    Sets the Input Manager touch callback to be SoundManager.unlock.

    Sets the Input Manager touch callback to be SoundManager.unlock. Required for iOS audio device unlocking. Mostly just used internally.

  41. def stopAll(): Unit

    Permalink

    Stops all the sounds in the game.

  42. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  43. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  44. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  45. var touchLocked: Boolean

    Permalink

    true if the audio system is currently locked awaiting a touch event.

  46. def unlock(): Boolean

    Permalink

    Enables the audio, usually after the first touch.

  47. def update(): Unit

    Permalink

    Updates every sound in the game, checks for audio unlock on mobile and monitors the decoding watch list.

    Updates every sound in the game, checks for audio unlock on mobile and monitors the decoding watch list. Internal: This member is internal (protected) and may be modified or removed in the future.

    Attributes
    protected
  48. def usingAudioTag: Boolean

    Permalink

    True the SoundManager and device are both using the Audio tag instead of Web Audio.

  49. def usingWebAudio: Boolean

    Permalink

    True the SoundManager and device are both using Web Audio.

  50. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  51. var volume: Int

    Permalink

    Gets or sets the global volume of the SoundManager, a value between 0 and 1.

    Gets or sets the global volume of the SoundManager, a value between 0 and 1. The value given is clamped to the range 0 to 1.

  52. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped