Skip to content

Play Music

Play Music

Begins playback of a music track, specified directly or constructed from variables for dynamic selection.

Properties

System

Name Explanation Type
Asset Name The audio asset file name when using variable mode. Variable or Value
Fade In The fade-in duration in milliseconds when using variable mode. Variable or Value
Loop Length The loop length in milliseconds when using variable mode. Variable or Value
Loop Start The loop start position in milliseconds when using variable mode. Variable or Value
Looping Whether the music loops continuously when using variable mode. Switch or Value
Music The music asset to play. Music
Offset (milliseconds) The playback offset in milliseconds from which the music begins playing. Variable or Value
Pan The stereo panning value when using variable mode. Ranges from -1 (left) to 1 (right). Variable or Value
Pitch The pitch adjustment when using variable mode. Variable or Value
Use Variable When enabled, the music track is constructed from variable values instead of a direct asset reference. Toggle
Volume The playback volume when using variable mode. Ranges from 0 (silent) to 1 (full volume). Variable or Value

Examples

Play a Music Track by Asset Reference

Plays a music track using a direct asset reference with default settings.

play_music({name: "Content/Audio/BattleTheme.ogg"});
{"Data":{"IsVariable":false,"Value":{"Name":"Content/Audio/BattleTheme.ogg","Volume":1,"Pitch":0,"Pan":0,"IsLooping":true,"FadeIn":"00:00:00","Position":"00:00:00","LoopStart":null,"LoopLength":null},"Offset":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"SwitchIsLooping":{"IsGlobalSwitch":false,"IsLocalSwitch":false,"IsValue":true,"Value":false,"SwitchIndex":0},"VariableFadeIn":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableLoopLength":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableLoopStart":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableName":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariablePan":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariablePitch":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableVolume":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"1","VariableIndex":0,"Metadata":null},"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Audio.PlayMusicCommand"}

Play a Music Track with Playback Offset

Plays a music track starting at 5000 milliseconds into the track.

play_music({name: "Content/Audio/BattleTheme.ogg"}, 5000);
{"Data":{"IsVariable":false,"Value":{"Name":"Content/Audio/BattleTheme.ogg","Volume":1,"Pitch":0,"Pan":0,"IsLooping":true,"FadeIn":"00:00:00","Position":"00:00:00","LoopStart":null,"LoopLength":null},"Offset":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"5000","VariableIndex":0,"Metadata":null},"SwitchIsLooping":{"IsGlobalSwitch":false,"IsLocalSwitch":false,"IsValue":true,"Value":false,"SwitchIndex":0},"VariableFadeIn":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableLoopLength":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableLoopStart":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableName":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariablePan":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariablePitch":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableVolume":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"1","VariableIndex":0,"Metadata":null},"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Audio.PlayMusicCommand"}

Play Music from Variables with Custom Settings

Plays a music track constructed from variable values with a custom name, volume, and looping enabled.

play_music(name: $gv[0], volume: 0.8, is_looping: true);
{"Data":{"IsVariable":true,"Value":{"Name":"","Volume":1,"Pitch":0,"Pan":0,"IsLooping":true,"FadeIn":"00:00:00","Position":"00:00:00","LoopStart":null,"LoopLength":null},"Offset":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"SwitchIsLooping":{"IsGlobalSwitch":false,"IsLocalSwitch":false,"IsValue":true,"Value":true,"SwitchIndex":0},"VariableFadeIn":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableLoopLength":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableLoopStart":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableName":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"VariablePan":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariablePitch":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableVolume":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0.8","VariableIndex":0,"Metadata":null},"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Audio.PlayMusicCommand"}