English
Class: SSWebAudioManager
Defined in: ssplayer-core/dist/audio.d.ts:59
Optional Web Audio API adapter implementing IAudioManager.
The player core never plays audio itself; it only surfaces sound references (via onAudio) and preloads them when an audio manager is attached. Nothing here touches a rendering engine — Web Audio is the browser's, not PixiJS's or WebGL's — so one copy serves every renderer, and the behaviour cannot drift between them.
It lives behind its own entry point (@spritestudio/ssplayer-core/audio) rather than the package index, so a build that never mentions sound does not carry it: ssplayer-webgl reaches it through a dynamic import() and keeps its ./lite build audio-free.
Usage:
ts
import { SSWebAudioManager } from '@spritestudio/ssplayer-core/audio';
new SSWebAudioManager().bindToPlayer(player); // preload + play wired in one call
await player.load('chara.ssab');
player.setAnimation('idle'); // sounds preload here (audioManager is set)
player.play();Implements
Constructors
Constructor
new SSWebAudioManager():
SSWebAudioManager
Defined in: ssplayer-core/dist/audio.d.ts:65
Returns
SSWebAudioManager
Methods
bindToPlayer()
bindToPlayer(
player): () =>void
Defined in: ssplayer-core/dist/audio.d.ts:93
Attaches this manager to a player: registers it as the player's audioManager (so setAnimation preloads the animation's sounds) and subscribes to onAudio so referenced sounds play automatically. Returns an unsubscribe function for the onAudio binding.
Sounds only while the playhead walks forwards: SpriteStudio has no reverse audio, and playing the keys a backward or ping-pong-return leg crosses would be a different sound from the one that was authored. The player still reports every key it crosses — the gate belongs here, on the playing, not on the reporting. Nor does a key on the frame a seek landed on: the playhead did not cross it.
Parameters
player
AudioBindablePlayer
Returns
() => void
initialize()
initialize():
Promise<void>
Defined in: ssplayer-core/dist/audio.d.ts:71
Initializes the Web Audio API context. Must be called after a user interaction (e.g., click) to comply with the browser's Autoplay Policy.
Returns
Promise<void>
play()
play(
soundName,loopNum?,partIndex?):AudioBufferSourceNode|null
Defined in: ssplayer-core/dist/audio.d.ts:97
Plays a preloaded sound instantly. If it's not preloaded, it will fetch and play it (with latency).
Parameters
soundName
string
loopNum?
number
partIndex?
number
Returns
AudioBufferSourceNode | null
preload()
preload(
sounds):Promise<void>
Defined in: ssplayer-core/dist/audio.d.ts:75
Preloads an array of sound assets and decodes them into memory.
Parameters
sounds
Returns
Promise<void>
Implementation of
release()
release(
soundNames):void
Defined in: ssplayer-core/dist/audio.d.ts:105
Releases specific sounds from memory to free up resources.
Parameters
soundNames
string[]
Returns
void
Implementation of
releaseAll()
releaseAll():
void
Defined in: ssplayer-core/dist/audio.d.ts:109
Releases all cached sounds and stops any currently playing audio.
Returns
void
Implementation of
stopAll()
stopAll():
void
Defined in: ssplayer-core/dist/audio.d.ts:101
Stop all currently playing sounds.
Returns
void