Music Streamer
Background streaming music player with seamless looping, crossfading, and volume attenuation.
Type: MusicNode · Category: Audio & Sound · Also found as: music
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
volume |
number | 1 |
Volume (0-1), before the bus and master volumes. Range 0 to 1. |
pitch |
number | 1 |
Playback speed / pitch (1 = normal). Range 0.1 to 3. |
pan |
number | 0.5 |
Stereo position: 0 left, 0.5 centre, 1 right. Range 0 to 1. |
bus |
string | "" |
The mixer bus it plays into (the Mixer tab; empty = Music): its fader, effects and output apply. |
caption |
string | "" |
Shown on the subtitle track when it starts, for players with sound captions on (e.g. “[calm music]”). |
looping |
boolean | true |
Start again at the end. |
autoplay |
boolean | false |
Start playing when the node becomes ready. |
isPlaying |
boolean | false |
Playing now. Runtime state: read-only, not saved. |
isPaused |
boolean | false |
Paused now. Runtime state: read-only, not saved. |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
MusicNode:connect(event, handler)
Section titled “MusicNode:connect(event, handler)”Connects a handler to one of this node’s events: finished (Playback (or the dialogue) ended); the tree events; custom ones.
self.node:connect("finished", function(value, source) Log.info("finished") end)eventMusicNodeEvent|stringhandlerfun(value:any, source: MusicNode)
Returns integer id Connection id for disconnect
MusicNode:get_property(path)
Section titled “MusicNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("volume")pathMusicNodeProperty|string
Returns any
MusicNode:set_property(path, value, y)
Section titled “MusicNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("volume", 1.5)pathMusicNodeProperty|stringvalueanyy?number
MusicNode:music_play()
Section titled “MusicNode:music_play()”Plays or resumes the background music on this MusicNode.
Scene.find_node("Music"):music_play()MusicNode:music_stop()
Section titled “MusicNode:music_stop()”Stops background music on this MusicNode.
Scene.find_node("Music"):music_stop()MusicNode:music_pause()
Section titled “MusicNode:music_pause()”Pauses background music on this MusicNode.
Scene.find_node("Music"):music_pause()MusicNode:music_resume()
Section titled “MusicNode:music_resume()”Resumes paused background music on this MusicNode.
Scene.find_node("Music"):music_resume()MusicNode:music_fade(volume, seconds, stop_at_end)
Section titled “MusicNode:music_fade(volume, seconds, stop_at_end)”Fades this MusicNode’s volume to volume (0..1) over seconds, starting
it if it isn’t playing.
Scene.find_node("Music"):music_fade(0, 2.0, true)volumenumbersecondsnumberstop_at_end?booleanStop when the fade reaches 0
In a scene file
Section titled “In a scene file”{ "type": "MusicNode", "name": "MusicStreamer", "position": [ 0, 0 ], "properties": { "volume": 1, "pitch": 1, "pan": 0.5 }}