Remarks
Manages a collection of namedHTMLAudioElement instances and ensures
only one track plays at a time — unlike SoundLibrary, starting a new
track pauses whichever one was playing.
Extends
Library
Implements
Constructors
Constructor
new MusicLibrary(Defined in: packages/common/dist/index.d.ts:510relationships?):MusicLibrary
Parameters
relationships?
Partial<LibraryRelationships>
Optional ordering overrides, keyed by other
libraries’ key.
Returns
MusicLibrary
Inherited from
Library.constructor
Properties
key
Defined in: modules/music/src/music.library.ts:15 This library’s identity: its slot onreadonlykey:"music"
Context, its registry key, and
the identifier used to reference it in ordering relationships.
Overrides
Library.key
Accessors
relationships
Get Signature
get relationships(): LibraryRelationships
Defined in: packages/common/dist/index.d.ts:512
Internal
Returns
LibraryRelationships
Inherited from
Library.relationships
Methods
__clear()
__clear():Defined in: modules/music/src/music.library.ts:37 Called once after the tick loop stops.Promise<void>
Returns
Promise<void>
Overrides
Library.__clear
__editorInit()
__editorInit(Defined in: modules/music/src/music.library.ts:30 Listens to the editor’sctx):Promise<void>
mute command.
Parameters
ctx
EditorInitContext
Returns
Promise<void>
Implementation of
EditorAwareLibrary.__editorInit
__events()
__events(Defined in: packages/common/dist/index.d.ts:521 Called every tick, in run order, whether or not the tick loop is paused — unlike_ctx):Promise<void>
__run. Use this for event/message draining that must
not be affected by pause (e.g. listening for the command that resumes
the loop), not for gameplay simulation.
Parameters
_ctx
Context
Returns
Promise<void>
Inherited from
Library.__events
__init()
__init():Defined in: modules/music/src/music.library.ts:23 Called once, in dependency order, before the tick loop starts.Promise<void>
Returns
Promise<void>
Overrides
Library.__init
__run()
__run(Defined in: packages/common/dist/index.d.ts:523 Called every tick, in run order, while the tick loop is active and not paused._ctx):Promise<void>
Parameters
_ctx
Context
Returns
Promise<void>
Inherited from
Library.__run
expose()
expose(): MusicContextApi
Defined in: modules/music/src/music.library.ts:83
Returns this library’s public contribution to Context[this.key].
Returns
MusicContextApi
Remarks
Return a plain object exposing only what game code should be able to reach — neverthis — so internal state and lifecycle hooks never leak
onto Context. Libraries with nothing to expose (headless libraries)
can leave this unimplemented; they simply won’t appear on Context.
Overrides
Library.expose
load()
load(Defined in: modules/music/src/music.library.ts:51 Registers a music track under a unique key.key,file):void
Parameters
key
string
file
string
Returns
void
Remarks
Creates anHTMLAudioElement from the given URL. The track respects
the current muted state at load time.
mute()
mute(): void
Defined in: modules/music/src/music.library.ts:77
Toggles the muted state of every loaded track.
Returns
void
play()
play(Defined in: modules/music/src/music.library.ts:61key):void
Parameters
key
string
Returns
void
Throws
NfNotFound When no track is registered under the given key.
throwNotInitializedError()
Defined in: packages/common/dist/index.d.ts:536protectedthrowNotInitializedError():never
Returns
never
Inherited from
Library.throwNotInitializedError